From f3a4a8d0437653762a15d7d8d6d134d1b4c3f9c1 Mon Sep 17 00:00:00 2001 From: "hkrn (a.k.a shimacpyon)" <129939+hkrn@users.noreply.github.com> Date: Mon, 30 May 2022 01:36:34 +0900 Subject: [PATCH] [nanodxm] fixed a bug cannot read int/float properly (#145) This commit fixed a bug of reading int/float due to incorrect pointer calculation caused in 2fadbbb2b48c3893b609eb8821a6dca2809d997f. --- dependencies/nanodxm/nanodxm_p.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/dependencies/nanodxm/nanodxm_p.h b/dependencies/nanodxm/nanodxm_p.h index 39fb2bc3..2107cdfe 100644 --- a/dependencies/nanodxm/nanodxm_p.h +++ b/dependencies/nanodxm/nanodxm_p.h @@ -346,12 +346,12 @@ nanodxmBufferReadStackString(nanodxm_buffer_t *buffer, char *stack, nanodxm_rsiz NANODXM_DECL_INLINE static void nanodxmBufferExtractInt(nanodxm_buffer_t *buffer, int *value) { - char stack[16], *ptr, *end; + char stack[16], *ptr, *end = NULL; nanodxmBufferSkipSpaces(buffer); if ((ptr = (char *) nanodxmBufferGetDataPtr(buffer)) != NULL) { nanodxmBufferReadStackString(buffer, stack, sizeof(stack)); *value = strtol(stack, &end, 10); - buffer->offset += end - ptr; + buffer->offset += end - stack; nanodxmBufferSkipSpaces(buffer); } else { @@ -362,12 +362,12 @@ nanodxmBufferExtractInt(nanodxm_buffer_t *buffer, int *value) NANODXM_DECL_INLINE static void nanodxmBufferExtractSize(nanodxm_buffer_t *buffer, nanodxm_rsize_t *value) { - char stack[16], *ptr, *end; + char stack[16], *ptr, *end = NULL; nanodxmBufferSkipSpaces(buffer); if ((ptr = (char *) nanodxmBufferGetDataPtr(buffer)) != NULL) { nanodxmBufferReadStackString(buffer, stack, sizeof(stack)); - *value = (nanodxm_rsize_t) strtol(ptr, &end, 10); - buffer->offset += end - ptr; + *value = (nanodxm_rsize_t) strtol(stack, &end, 10); + buffer->offset += end - stack; nanodxmBufferSkipSpaces(buffer); } else { @@ -378,12 +378,12 @@ nanodxmBufferExtractSize(nanodxm_buffer_t *buffer, nanodxm_rsize_t *value) NANODXM_DECL_INLINE static void nanodxmBufferExtractFloat(nanodxm_buffer_t *buffer, float *value) { - char stack[16], *ptr, *end; + char stack[16], *ptr, *end = NULL; nanodxmBufferSkipSpaces(buffer); if ((ptr = (char *) nanodxmBufferGetDataPtr(buffer)) != NULL) { nanodxmBufferReadStackString(buffer, stack, sizeof(stack)); *value = (float) strtod(stack, &end); - buffer->offset += end - ptr; + buffer->offset += end - stack; nanodxmBufferSkipSpaces(buffer); } else {