Fix memory leaks reported by Address Sanitizer.
[pspp] / src / output / options.c
index 8d15d1cc4a7162b57b034443c46eb44d266b4ab5..74bc751c5595bed2137ef3f6e110c91e5cf80850 100644 (file)
@@ -607,20 +607,15 @@ parse_color__ (const char *s, struct cell_color *color)
 struct cell_color
 parse_color (struct driver_option *o)
 {
+  struct cell_color color = CELL_COLOR_BLACK;
+  parse_color__ (o->default_value, &color);
   if (o->value)
     {
-      struct cell_color color;
-      if (parse_color__ (o->value, &color))
-        return color;
-
-      msg (MW, _("%s: `%s' is `%s', which could not be parsed as a color"),
-           o->driver_name, o->name, o->value);
+      if (!parse_color__ (o->value, &color))
+        msg (MW, _("%s: `%s' is `%s', which could not be parsed as a color"),
+             o->driver_name, o->name, o->value);
     }
-
-  struct cell_color color;
-  if (parse_color__ (o->default_value, &color))
-    return color;
-
-  return (struct cell_color) CELL_COLOR_BLACK;
+  driver_option_destroy (o);
+  return color;
 }