Skip to content

Commit 84237ff

Browse files
committed
Replace sizeof('\0') with sizeof("")
Because sizeof('\0') is actually sizeof(int) not sizeof(char).
1 parent ab8489a commit 84237ff

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

cJSON.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ static const unsigned char *parse_string(cJSON * const item, const unsigned char
628628

629629
/* This is at most how much we need for the output */
630630
allocation_length = (size_t) (input_end - input) - skipped_bytes;
631-
output = (unsigned char*)hooks->allocate(allocation_length + sizeof('\0'));
631+
output = (unsigned char*)hooks->allocate(allocation_length + sizeof(""));
632632
if (output == NULL)
633633
{
634634
goto fail; /* allocation failure */
@@ -1101,7 +1101,7 @@ static cJSON_bool print_value(const cJSON * const item, const size_t depth, cons
11011101
return false;
11021102
}
11031103

1104-
raw_length = strlen(item->valuestring) + sizeof('\0');
1104+
raw_length = strlen(item->valuestring) + sizeof("");
11051105
output = ensure(output_buffer, raw_length, hooks);
11061106
if (output == NULL)
11071107
{

fuzzing/afl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static char *read_file(const char *filename)
5656
}
5757

5858
/* allocate content buffer */
59-
content = (char*)malloc((size_t)length + sizeof('\0'));
59+
content = (char*)malloc((size_t)length + sizeof(""));
6060
if (content == NULL)
6161
{
6262
goto cleanup;

tests/common.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ CJSON_PUBLIC(char*) read_file(const char *filename)
7070
}
7171

7272
/* allocate content buffer */
73-
content = (char*)malloc((size_t)length + sizeof('\0'));
73+
content = (char*)malloc((size_t)length + sizeof(""));
7474
if (content == NULL)
7575
{
7676
goto cleanup;

0 commit comments

Comments
 (0)