diff options
-rw-r--r-- | plugins/check_http.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/plugins/check_http.c b/plugins/check_http.c index c23625e..5fa310f 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c | |||
@@ -1438,7 +1438,8 @@ char *unchunk_content(const char *content) { | |||
1438 | overall_size += length_of_chunk; | 1438 | overall_size += length_of_chunk; |
1439 | 1439 | ||
1440 | if (result == NULL) { | 1440 | if (result == NULL) { |
1441 | result = (char *)calloc(length_of_chunk, sizeof(char)); | 1441 | // Size of the chunk plus the ending NULL byte |
1442 | result = (char *)malloc(length_of_chunk +1); | ||
1442 | if (result == NULL) { | 1443 | if (result == NULL) { |
1443 | if (verbose) { | 1444 | if (verbose) { |
1444 | printf("Failed to allocate memory for unchunked body\n"); | 1445 | printf("Failed to allocate memory for unchunked body\n"); |
@@ -1446,7 +1447,8 @@ char *unchunk_content(const char *content) { | |||
1446 | return NULL; | 1447 | return NULL; |
1447 | } | 1448 | } |
1448 | } else { | 1449 | } else { |
1449 | void *tmp = realloc(result, overall_size); | 1450 | // Enlarge memory to the new size plus the ending NULL byte |
1451 | void *tmp = realloc(result, overall_size +1); | ||
1450 | if (tmp == NULL) { | 1452 | if (tmp == NULL) { |
1451 | if (verbose) { | 1453 | if (verbose) { |
1452 | printf("Failed to allocate memory for unchunked body\n"); | 1454 | printf("Failed to allocate memory for unchunked body\n"); |