lib: json: Fix number parsing
Comparing *endptr with '\0' will always be true before replacing *token->end with prev_end. Jira: ZEP-1607 Change-Id: I224129586e15380d3919bfba3db4fcf38c28cb07 Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
This commit is contained in:
parent
122cdb3956
commit
844ef6744e
1 changed files with 2 additions and 3 deletions
|
@ -389,8 +389,7 @@ static int arr_next(struct json_obj *json, struct token *value)
|
|||
static int decode_num(const struct token *token, int32_t *num)
|
||||
{
|
||||
/* FIXME: strtod() is not available in newlib/minimal libc,
|
||||
* so using strtol() here; this means no floating point
|
||||
* numbers.
|
||||
* so using strtol() here.
|
||||
*/
|
||||
char *endptr;
|
||||
char prev_end;
|
||||
|
@ -407,7 +406,7 @@ static int decode_num(const struct token *token, int32_t *num)
|
|||
return -errno;
|
||||
}
|
||||
|
||||
if (*endptr) {
|
||||
if (endptr != token->end) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue