From 0f271dcf6383d487c62e71e682fa85f273015d0f Mon Sep 17 00:00:00 2001 From: Max Bruckner Date: Thu, 16 Feb 2017 20:26:40 +0100 Subject: [PATCH] parse_hex4: make input pointer const --- cJSON.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/cJSON.c b/cJSON.c index 7be47b1..aef9824 100644 --- a/cJSON.c +++ b/cJSON.c @@ -368,7 +368,7 @@ static unsigned char *print_number(const cJSON *item, printbuffer *p) } /* parse 4 digit hexadecimal number */ -static unsigned parse_hex4(const unsigned char *str) +static unsigned parse_hex4(const unsigned char * const input) { unsigned int h = 0; size_t i = 0; @@ -376,17 +376,17 @@ static unsigned parse_hex4(const unsigned char *str) for (i = 0; i < 4; i++) { /* parse digit */ - if ((*str >= '0') && (*str <= '9')) + if ((input[i] >= '0') && (input[i] <= '9')) { - h += (unsigned int) (*str) - '0'; + h += (unsigned int) input[i] - '0'; } - else if ((*str >= 'A') && (*str <= 'F')) + else if ((input[i] >= 'A') && (input[i] <= 'F')) { - h += (unsigned int) 10 + (*str) - 'A'; + h += (unsigned int) 10 + input[i] - 'A'; } - else if ((*str >= 'a') && (*str <= 'f')) + else if ((input[i] >= 'a') && (input[i] <= 'f')) { - h += (unsigned int) 10 + (*str) - 'a'; + h += (unsigned int) 10 + input[i] - 'a'; } else /* invalid */ { @@ -397,7 +397,6 @@ static unsigned parse_hex4(const unsigned char *str) { /* shift left to make place for the next nibble */ h = h << 4; - str++; } }