summaryrefslogtreecommitdiff
blob: 34e539f51e2d92c8410085f13b947fd2b557318c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
https://bugs.gentoo.org/893252
https://github.com/monitoring-plugins/monitoring-plugins/issues/1836
https://github.com/monitoring-plugins/monitoring-plugins/commit/6d3e44d2d8395076060e9c741e9b173dc5d57b76

diff --git a/plugins/check_http.c b/plugins/check_http.c
index 5fa310f5d..8dda046ff 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -1462,7 +1462,13 @@ char *unchunk_content(const char *content) {
     memcpy(result + (overall_size - size_of_chunk), start_of_chunk, size_of_chunk);
   }
 
-  result[overall_size] = '\0';
+  if (overall_size == 0 && result == NULL) {
+    // We might just have received the end chunk without previous content, so result is never allocated
+    result = calloc(1, sizeof(char));
+    // No error handling here, we can only return NULL anyway
+  } else {
+    result[overall_size] = '\0';
+  }
   return result;
 }