pgvector.git / summary / log / commit / refs
commit c13e4fc299255293dff43eb87301b03c12c1c5fe
Author: Andrew Kane <andrew@ankane.org>
Date: Wed Jul 29 00:04:42 2026 +0000
Hardened out functions [skip ci]
src/halfvec.c | 2 +-
src/sparsevec.c | 2 +-
src/vector.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/halfvec.c b/src/halfvec.c
index d5996f3e..2ef52ad8 100644
--- a/src/halfvec.c
+++ b/src/halfvec.c
@@ -314,7 +314,7 @@ halfvec_out(PG_FUNCTION_ARGS)
*
* 3 bytes for [, ], and \0
*/
- buf = (char *) palloc(FLOAT_SHORTEST_DECIMAL_LEN * dim + 3);
+ buf = (char *) palloc(add_size(mul_size(FLOAT_SHORTEST_DECIMAL_LEN, dim), 3));
ptr = buf;
AppendChar(ptr, '[');
diff --git a/src/sparsevec.c b/src/sparsevec.c
index fbba0225..3dfa455e 100644
--- a/src/sparsevec.c
+++ b/src/sparsevec.c
@@ -450,7 +450,7 @@ sparsevec_out(PG_FUNCTION_ARGS)
*
* 4 bytes for {, }, /, and \0
*/
- buf = (char *) palloc((12 + FLOAT_SHORTEST_DECIMAL_LEN) * sparsevec->nnz + 15);
+ buf = (char *) palloc(add_size(mul_size(12 + FLOAT_SHORTEST_DECIMAL_LEN, sparsevec->nnz), 15));
ptr = buf;
AppendChar(ptr, '{');
diff --git a/src/vector.c b/src/vector.c
index 80cdacbb..860e13f1 100644
--- a/src/vector.c
+++ b/src/vector.c
@@ -309,7 +309,7 @@ vector_out(PG_FUNCTION_ARGS)
*
* 3 bytes for [, ], and \0
*/
- buf = (char *) palloc(FLOAT_SHORTEST_DECIMAL_LEN * dim + 3);
+ buf = (char *) palloc(add_size(mul_size(FLOAT_SHORTEST_DECIMAL_LEN, dim), 3));
ptr = buf;
AppendChar(ptr, '[');
[parent: 5c97c034a601]