Added extra bytes to buffer for safety in the event of negative integers [skip ci]

(cherry picked from commit 29e94adf7942a350669aad1b14dc3410a6f2d0f3)
This commit is contained in:
Andrew Kane
2026-09-11 13:47:34 -07:00
committed by zeekay
parent dbc5c4a3e7
commit 4d286d3899
+3 -3
View File
@@ -427,7 +427,7 @@ sparsevec_out(PG_FUNCTION_ARGS)
/*
* Need:
*
* nnz * 10 bytes for index (positive integer)
* nnz * 11 bytes for index (includes sign for extra safety)
*
* nnz bytes for :
*
@@ -436,11 +436,11 @@ sparsevec_out(PG_FUNCTION_ARGS)
*
* max(nnz - 1, 0) bytes for ,
*
* 10 bytes for dimensions
* 11 bytes for dimensions (includes sign for extra safety)
*
* 4 bytes for {, }, /, and \0
*/
buf = (char *) palloc((11 + FLOAT_SHORTEST_DECIMAL_LEN) * sparsevec->nnz + 14);
buf = (char *) palloc((12 + FLOAT_SHORTEST_DECIMAL_LEN) * sparsevec->nnz + 15);
ptr = buf;
AppendChar(ptr, '{');