Skip to content

Commit c7667f4

Browse files
authored
Fix Invalid read of size 2 in numeric_add (babelfish-for-postgresql#618)
This commit fixes the nvalid read of size 2 in numeric_add_opt_error by checking if result.ndigits > 0 before calling result.digits[0]. Task: BABEL-5945 Signed-off-by: yashneet vinayak yashneet@amazon.com
1 parent 7faa775 commit c7667f4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/backend/utils/adt/numeric.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2925,7 +2925,7 @@ numeric_add_opt_error(Numeric num1, Numeric num2, bool *have_error)
29252925
init_var(&result);
29262926
add_var(&arg1, &arg2, &result);
29272927

2928-
if (detect_numeric_overflow_hook && result.digits &&
2928+
if (detect_numeric_overflow_hook && result.digits && result.ndigits > 0 &&
29292929
(*detect_numeric_overflow_hook)(result.weight, result.dscale, result.digits[0], DEC_DIGITS))
29302930
ereport(ERROR,
29312931
(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),

0 commit comments

Comments
 (0)