write_stackdriver plugin: Check pointer for NULL before dereferencing it.
authorFlorian Forster <octo@collectd.org>
Thu, 18 Oct 2018 13:49:37 +0000 (15:49 +0200)
committerFlorian Forster <ff@octo.it>
Thu, 18 Oct 2018 16:52:13 +0000 (18:52 +0200)
src/write_stackdriver.c

index 9d06c25..421df2d 100644 (file)
@@ -225,8 +225,10 @@ static int do_post(wg_callback_t *cb, char const *url, void const *payload,
 
   if (status != CURLE_OK) {
     ERROR("write_stackdriver plugin: POST %s failed: %s", url, cb->curl_errbuf);
-    sfree(ret_content->memory);
-    ret_content->size = 0;
+    if (ret_content != NULL) {
+      sfree(ret_content->memory);
+      ret_content->size = 0;
+    }
     return -1;
   }