Added extra byte to buffers for safety in the event of an empty vector [skip ci]

(cherry picked from commit a3cf81a784169dacb7785e6a757cf6ebae15371a)
This commit is contained in:
Andrew Kane
2026-09-11 13:47:34 -07:00
committed by zeekay
parent c3f4fed396
commit dbc5c4a3e7
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -300,11 +300,11 @@ halfvec_out(PG_FUNCTION_ARGS)
* dim * (FLOAT_SHORTEST_DECIMAL_LEN - 1) bytes for
* float_to_shortest_decimal_bufn
*
* dim - 1 bytes for separator
* max(dim - 1, 0) bytes for separator
*
* 3 bytes for [, ], and \0
*/
buf = (char *) palloc(FLOAT_SHORTEST_DECIMAL_LEN * dim + 2);
buf = (char *) palloc(FLOAT_SHORTEST_DECIMAL_LEN * dim + 3);
ptr = buf;
AppendChar(ptr, '[');
+2 -2
View File
@@ -295,11 +295,11 @@ vector_out(PG_FUNCTION_ARGS)
* dim * (FLOAT_SHORTEST_DECIMAL_LEN - 1) bytes for
* float_to_shortest_decimal_bufn
*
* dim - 1 bytes for separator
* max(dim - 1, 0) bytes for separator
*
* 3 bytes for [, ], and \0
*/
buf = (char *) palloc(FLOAT_SHORTEST_DECIMAL_LEN * dim + 2);
buf = (char *) palloc(FLOAT_SHORTEST_DECIMAL_LEN * dim + 3);
ptr = buf;
AppendChar(ptr, '[');