Null pointer passed as source to memcpy() in numeric.c:make_result() and numeric:set_var_from_var()
Hello,
these two queries will make the assertions below fail:
SELECT STDDEV(0.0);
SELECT 0.0 * 0;
diff --git a/src/backend/utils/adt/numeric.c
b/src/backend/utils/adt/numeric.c
index 7ce41b7..6e642d8 100644
--- a/src/backend/utils/adt/numeric.c
+++ b/src/backend/utils/adt/numeric.c
@@ -4769,6 +4769,7 @@ set_var_from_var(NumericVar *value, NumericVar *dest)
newbuf = digitbuf_alloc(value->ndigits + 1);
newbuf[0] = 0; /* spare digit for
rounding */
+ Assert(value->digits != NULL);
memcpy(newbuf + 1, value->digits, value->ndigits *
sizeof(NumericDigit));
digitbuf_free(dest->buf);
@@ -5090,6 +5091,7 @@ make_result(NumericVar *var)
result->choice.n_long.n_weight = weight;
}
+ Assert(digits != NULL);
memcpy(NUMERIC_DIGITS(result), digits, n * sizeof(NumericDigit));
Assert(NUMERIC_NDIGITS(result) == n);
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Piotr Stefaniak <postgres@piotr-stefaniak.me> writes:
these two queries will make the assertions below fail:
SELECT STDDEV(0.0);
SELECT 0.0 * 0;
Fixed, thanks.
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers