Fix memleaks in new category code
authorAndre Heinecke <aheinecke@intevation.de>
Tue, 16 Oct 2018 08:52:57 +0000 (10:52 +0200)
committerAndre Heinecke <aheinecke@intevation.de>
Tue, 16 Oct 2018 08:52:57 +0000 (10:52 +0200)
* src/categorymanager.cpp,
src/oomhelp.cpp (get_store_for_id, delete_category): Fix leaks.

src/categorymanager.cpp
src/oomhelp.cpp

index 1716b52..e671f2d 100644 (file)
@@ -48,8 +48,10 @@ public:
         {
           log_debug ("%s:%s: Failed to create category %s",
                      SRCNAME, __func__, anonstr (category.c_str()));
+          gpgol_release (categories);
           TRETURN;
         }
+      gpgol_release (categories);
       TRETURN;
     }
 
@@ -131,6 +133,7 @@ public:
               TRETURN;
             }
           delete_category (store, category.c_str ());
+          gpgol_release (store);
           storeIt->second.erase (categoryIt);
         }
       TRETURN;
index 1cc2d0b..b859cb7 100644 (file)
@@ -1879,12 +1879,14 @@ get_store_for_id (const char *storeID)
       if (id && !strcmp (id, storeID))
         {
           gpgol_release (stores);
+          xfree (id);
           return store;
         }
+      xfree (id);
       gpgol_release (store);
     }
   gpgol_release (stores);
-  return nullptr;
+  TRETURN nullptr;
 }
 
 void
@@ -2106,6 +2108,7 @@ delete_category (LPDISPATCH store, const char *category)
               log_debug ("%s:%s: Deleted category '%s'",
                          SRCNAME, __func__, anonstr (category));
             }
+          xfree (name);
           break;
         }
       xfree (name);