mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-10 06:40:57 +08:00
Check bounds unconditionally in array_to_vector(). (#127)
Presently, array_to_vector()'s call to CheckDim() is skipped when typmod != -1, which allows for bypassing VECTOR_MAX_DIM. To fix, call Check[Expected]Dim() unconditionally. CheckExpectedDim() takes no action when typmod == -1, so there's no need to guard it with an 'if' statement.
This commit is contained in:
@@ -396,10 +396,8 @@ array_to_vector(PG_FUNCTION_ARGS)
|
|||||||
get_typlenbyvalalign(ARR_ELEMTYPE(array), &typlen, &typbyval, &typalign);
|
get_typlenbyvalalign(ARR_ELEMTYPE(array), &typlen, &typbyval, &typalign);
|
||||||
deconstruct_array(array, ARR_ELEMTYPE(array), typlen, typbyval, typalign, &elemsp, &nullsp, &nelemsp);
|
deconstruct_array(array, ARR_ELEMTYPE(array), typlen, typbyval, typalign, &elemsp, &nullsp, &nelemsp);
|
||||||
|
|
||||||
if (typmod == -1)
|
CheckDim(nelemsp);
|
||||||
CheckDim(nelemsp);
|
CheckExpectedDim(typmod, nelemsp);
|
||||||
else
|
|
||||||
CheckExpectedDim(typmod, nelemsp);
|
|
||||||
|
|
||||||
result = InitVector(nelemsp);
|
result = InitVector(nelemsp);
|
||||||
for (i = 0; i < nelemsp; i++)
|
for (i = 0; i < nelemsp; i++)
|
||||||
|
|||||||
Reference in New Issue
Block a user