Skip to content

Commit

Permalink
[nanodxm] fixed a bug cannot read int/float properly (#145)
Browse files Browse the repository at this point in the history
This commit fixed a bug of reading int/float due to incorrect
pointer calculation caused in 2fadbbb.
  • Loading branch information
hkrn authored May 29, 2022
1 parent 6530e71 commit f3a4a8d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions dependencies/nanodxm/nanodxm_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit f3a4a8d

Please sign in to comment.