Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite2ceff1

Browse files
committed
postgres: Use pg_{add,mul}_size_overflow()
The backend implementations of add_size() and mul_size() can now makeuse of the APIs provided in common/int.h.Reviewed-by: Chao Li <li.evan.chao@gmail.com>Reviewed-by: Michael Paquier <michael@paquier.xyz>Discussion:https://postgr.es/m/CAOYmi%2B%3D%2BpqUd2MUitvgW1pAJuXgG_TKCVc3_Ek7pe8z9nkf%2BAg%40mail.gmail.com
1 parent8934f21 commite2ceff1

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

‎src/backend/storage/ipc/shmem.c‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565

6666
#include"postgres.h"
6767

68+
#include"common/int.h"
6869
#include"fmgr.h"
6970
#include"funcapi.h"
7071
#include"miscadmin.h"
@@ -495,9 +496,7 @@ add_size(Size s1, Size s2)
495496
{
496497
Sizeresult;
497498

498-
result=s1+s2;
499-
/* We are assuming Size is an unsigned type here... */
500-
if (result<s1||result<s2)
499+
if (pg_add_size_overflow(s1,s2,&result))
501500
ereport(ERROR,
502501
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
503502
errmsg("requested shared memory size overflows size_t")));
@@ -512,11 +511,7 @@ mul_size(Size s1, Size s2)
512511
{
513512
Sizeresult;
514513

515-
if (s1==0||s2==0)
516-
return0;
517-
result=s1*s2;
518-
/* We are assuming Size is an unsigned type here... */
519-
if (result /s2!=s1)
514+
if (pg_mul_size_overflow(s1,s2,&result))
520515
ereport(ERROR,
521516
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
522517
errmsg("requested shared memory size overflows size_t")));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp