From bab1bc7725d5af34de941244ba6a5dc31585737b Mon Sep 17 00:00:00 2001 From: rghouzra Date: Thu, 20 Nov 2025 07:08:52 +0100 Subject: [PATCH] fix decode_pointer_inplace to handle escape sequences correctly --- cJSON_Utils.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cJSON_Utils.c b/cJSON_Utils.c index 8fa24f8e..5996e13f 100644 --- a/cJSON_Utils.c +++ b/cJSON_Utils.c @@ -371,18 +371,23 @@ static void decode_pointer_inplace(unsigned char *string) if (string[1] == '0') { decoded_string[0] = '~'; + string++; } else if (string[1] == '1') { - decoded_string[1] = '/'; + decoded_string[0] = '/'; + string++; } else { /* invalid escape sequence */ + *decoded_string = '\0'; return; } - - string++; + } + else + { + decoded_string[0] = string[0]; } }