Skip to content

Commit

Permalink
Replace sizeof('\0') with sizeof("")
Browse files Browse the repository at this point in the history
Because sizeof('\0') is actually sizeof(int) not sizeof(char).
  • Loading branch information
FSMaxB committed Apr 7, 2017
1 parent ab8489a commit 84237ff
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cJSON.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ static const unsigned char *parse_string(cJSON * const item, const unsigned char

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

raw_length = strlen(item->valuestring) + sizeof('\0');
raw_length = strlen(item->valuestring) + sizeof("");
output = ensure(output_buffer, raw_length, hooks);
if (output == NULL)
{
Expand Down
2 changes: 1 addition & 1 deletion fuzzing/afl.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static char *read_file(const char *filename)
}

/* allocate content buffer */
content = (char*)malloc((size_t)length + sizeof('\0'));
content = (char*)malloc((size_t)length + sizeof(""));
if (content == NULL)
{
goto cleanup;
Expand Down
2 changes: 1 addition & 1 deletion tests/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ CJSON_PUBLIC(char*) read_file(const char *filename)
}

/* allocate content buffer */
content = (char*)malloc((size_t)length + sizeof('\0'));
content = (char*)malloc((size_t)length + sizeof(""));
if (content == NULL)
{
goto cleanup;
Expand Down

0 comments on commit 84237ff

Please sign in to comment.