Skip to content

Commit 22c2980

Browse files
hamchapmanthiagomacieira
authored andcommitted
If the buffer pointer is a null pointer then don't apply an offset to it
1 parent 02a7efc commit 22c2980

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/cborparser.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,7 @@ static CborError iterate_string_chunks(const CborValue *value, char *buffer, siz
12111211
return CborErrorDataTooLarge;
12121212

12131213
if (*result && *buflen >= newTotal)
1214-
*result = !!func(buffer + total, (const uint8_t *)ptr, chunkLen);
1214+
*result = !!func(buffer == NULL ? buffer : buffer + total, (const uint8_t *)ptr, chunkLen);
12151215
else
12161216
*result = false;
12171217

@@ -1221,7 +1221,7 @@ static CborError iterate_string_chunks(const CborValue *value, char *buffer, siz
12211221
/* is there enough room for the ending NUL byte? */
12221222
if (*result && *buflen > total) {
12231223
uint8_t nul[] = { 0 };
1224-
*result = !!func(buffer + total, nul, 1);
1224+
*result = !!func(buffer == NULL ? buffer : buffer + total, nul, 1);
12251225
}
12261226
*buflen = total;
12271227
return _cbor_value_finish_string_iteration(next);

0 commit comments

Comments
 (0)