]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
write_prometheus plugin: Complete error handling in `prom_metric_family_clone()`.
authorFlorian Forster <octo@collectd.org>
Tue, 20 Feb 2024 14:50:17 +0000 (15:50 +0100)
committerFlorian Forster <octo@collectd.org>
Tue, 20 Feb 2024 15:01:01 +0000 (16:01 +0100)
src/write_prometheus.c

index 4861766b44d355b8fe2bc9e2d47e70e7a48fef3a..9cf2f4d833d07a919600fe2a0100770db962f073 100644 (file)
@@ -665,9 +665,20 @@ prom_metric_family_clone(metric_family_t const *fam) {
 
   if (fam->help != NULL) {
     pfam->help = strdup(fam->help);
+    if (pfam->help == NULL) {
+      sfree(pfam->name);
+      sfree(pfam);
+      return NULL;
+    }
   }
   if (fam->unit != NULL) {
     pfam->unit = strdup(fam->unit);
+    if (pfam->unit == NULL) {
+      sfree(pfam->help);
+      sfree(pfam->name);
+      sfree(pfam);
+      return NULL;
+    }
   }
 
   return pfam;