Code

Don't access freed memory
authorRuben Kerkhof <ruben@rubenkerkhof.com>
Tue, 30 Jun 2015 12:13:24 +0000 (14:13 +0200)
committerMarc Fournier <marc.fournier@camptocamp.com>
Fri, 11 Sep 2015 21:00:12 +0000 (23:00 +0200)
The fields array contains pointers into the value_copy string.

src/virt.c

index 69a46071f339b5fab303e3af1c56c1affe08c819..663555b9bd33a2375d717482987041824a3f5c76 100644 (file)
@@ -417,8 +417,8 @@ lv_config (const char *key, const char *value)
             else if (strcasecmp (fields[i], "uuid") == 0)
                 hostname_format[i] = hf_uuid;
             else {
-                sfree (value_copy);
                 ERROR (PLUGIN_NAME " plugin: unknown HostnameFormat field: %s", fields[i]);
+                sfree (value_copy);
                 return -1;
             }
         }
@@ -454,8 +454,8 @@ lv_config (const char *key, const char *value)
             else if (strcasecmp (fields[i], "uuid") == 0)
                 plugin_instance_format[i] = plginst_uuid;
             else {
-                sfree (value_copy);
                 ERROR (PLUGIN_NAME " plugin: unknown PluginInstanceFormat field: %s", fields[i]);
+                sfree (value_copy);
                 return -1;
             }
         }