]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
text protocol: Fix memory leak in PUTVAL parsing.
authorRafael Marinheiro <marinheiro@google.com>
Mon, 21 May 2018 16:12:30 +0000 (12:12 -0400)
committerDagobert Michelsen <dam@opencsw.org>
Wed, 19 Feb 2020 17:15:52 +0000 (18:15 +0100)
src/utils/cmds/putval.c

index 77debe352404cabb9684164d7a997ea0b8ff4d86..86368837d3dc8849f87fee0b9c6171eabf4b0a9a 100644 (file)
@@ -71,7 +71,11 @@ static int set_option(value_list_t *vl, const char *key, const char *value) {
 
     if (is_quoted(value, value_len)) {
       const char *value_str = strndup(value + 1, value_len - 2);
-      return meta_data_add_string(vl->meta, meta_key, value_str);
+      if (value_str == NULL) {
+        return 1;
+      }
+      meta_data_add_string(vl->meta, meta_key, value_str);
+      free((void *)value_str);
     }
     return 1;
   } else {