Skip to content

Commit

Permalink
Fix: set p to endptr before checking
Browse files Browse the repository at this point in the history
Issue: #275
  • Loading branch information
vstakhov committed Feb 1, 2024
1 parent 25d3f51 commit 9eddef0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/ucl_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -833,20 +833,20 @@ ucl_maybe_parse_number (ucl_object_t *obj,
}

char numbuf[128];

if ((size_t)(p - c + 1) >= sizeof(numbuf)) {
*pos = start;
return EINVAL;
}

if (is_neg) {
numbuf[0] = '-';
ucl_strlcpy (&numbuf[1], c, p - c + 1);
}
else {
ucl_strlcpy (numbuf, c, p - c + 1);
}

errno = 0;
if (need_double) {
dv = strtod (numbuf, &endptr);
Expand Down Expand Up @@ -879,6 +879,7 @@ ucl_maybe_parse_number (ucl_object_t *obj,
}

if (endptr < end && endptr != start) {
p = endptr;
switch (*p) {
case 'm':
case 'M':
Expand Down

0 comments on commit 9eddef0

Please sign in to comment.