]> xenbits.xensource.com Git - libvirt.git/commitdiff
virNWFilterHashTablePut: Free the correct variable
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 23 May 2013 13:40:42 +0000 (15:40 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 23 May 2013 13:58:41 +0000 (15:58 +0200)
In bf1fe848 I've introduced 'newName' variable to substitute the old
'const char *name' as previously we had an ugly code there:

  name = strdup(name);

However, some parts of the function were not updated, so they were still
calling VIR_FREE(name) instead of VIR_FREE(newName).

src/conf/nwfilter_params.c

index ac5f7ed79491e0069706fe2a40a953c941a19cb7..48b89b7ffdb3c4b4241203caec45c8e13d50f2f0 100644 (file)
@@ -647,13 +647,13 @@ virNWFilterHashTablePut(virNWFilterHashTablePtr table,
                         int copyName)
 {
     if (!virHashLookup(table->hashTable, name)) {
+        char *newName;
         if (copyName) {
-            char *newName;
             if (VIR_STRDUP(newName, name) < 0)
                 return -1;
 
             if (VIR_REALLOC_N(table->names, table->nNames + 1) < 0) {
-                VIR_FREE(name);
+                VIR_FREE(newName);
                 return -1;
             }
             table->names[table->nNames++] = newName;
@@ -661,7 +661,7 @@ virNWFilterHashTablePut(virNWFilterHashTablePtr table,
 
         if (virHashAddEntry(table->hashTable, name, val) < 0) {
             if (copyName) {
-                VIR_FREE(name);
+                VIR_FREE(newName);
                 table->nNames--;
             }
             return -1;