Skip to content

Commit

Permalink
refactor(object_domain): no magic number for sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
vimkim committed Jan 6, 2025
1 parent 845b920 commit 7f48ac9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/object/object_domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -5010,9 +5010,11 @@ tp_str_to_vector (const DB_VALUE * src, DB_VALUE * result)
const char *p = db_get_string (src);
const char *end = p + db_get_string_size (src);
int count = 0;
char number_buffer[64];
const int number_buffer_size = 64;
char number_buffer[number_buffer_size];
int buffer_idx;
float float_array[2000];
const int max_vector_size = 2000;
float float_array[max_vector_size];
DB_SET *vec = NULL;
DB_VALUE e_val;
INTL_CODESET codeset = db_get_string_codeset (src);
Expand All @@ -5030,7 +5032,7 @@ tp_str_to_vector (const DB_VALUE * src, DB_VALUE * result)
}
p++;

while (p < end && count < 2000)
while (p < end && count < max_vector_size)
{
// Skip spaces before number
p = (char *) intl_skip_spaces (p, end, codeset);
Expand All @@ -5047,7 +5049,7 @@ tp_str_to_vector (const DB_VALUE * src, DB_VALUE * result)

// Get number into buffer
buffer_idx = 0;
while (p < end && *p != ',' && *p != ']' && buffer_idx < 63)
while (p < end && *p != ',' && *p != ']' && buffer_idx < number_buffer_size)
{
if (!isspace (*p))
{
Expand All @@ -5056,7 +5058,7 @@ tp_str_to_vector (const DB_VALUE * src, DB_VALUE * result)
p++;
}

if (buffer_idx == 0 || buffer_idx >= 63)
if (buffer_idx == 0 || buffer_idx >= number_buffer_size)
{

return ER_FAILED;
Expand Down

0 comments on commit 7f48ac9

Please sign in to comment.