Improved safety check [skip ci]

This commit is contained in:
Andrew Kane
2024-04-15 14:49:40 -07:00
parent a415420a1c
commit 7580e99205

View File

@@ -898,13 +898,13 @@ sparsevec_l2_normalize(PG_FUNCTION_ARGS)
if (rx[i] == 0)
continue;
newResult->indices[j] = result->indices[i];
nx[j] = rx[i];
j++;
/* Safety check */
if (j == newResult->nnz)
break;
newResult->indices[j] = result->indices[i];
nx[j] = rx[i];
j++;
}
pfree(result);