fixes memory leaks detected by cppcheck (or annotates them at least)

Thu, 31 Aug 2017 12:55:09 +0200

author
Mike Becker <universe@uap-core.de>
date
Thu, 31 Aug 2017 12:55:09 +0200
changeset 288
cd3846cc8b25
parent 287
99bcd7915a0d
child 289
0f83fe5e2b07

fixes memory leaks detected by cppcheck (or annotates them at least)

dav/scfg.c file | annotate | diff | comparison | revisions
dav/sync.c file | annotate | diff | comparison | revisions
libidav/davqlparser.c file | annotate | diff | comparison | revisions
--- a/dav/scfg.c	Thu Aug 31 12:44:25 2017 +0200
+++ b/dav/scfg.c	Thu Aug 31 12:55:09 2017 +0200
@@ -84,6 +84,7 @@
     if (regcomp(regex, value, REG_EXTENDED|REG_NOSUB)) {
         print_warning(xmlline,
                 "Invalid regular expression (%s) ... skipped\n", value);
+        free(regex);
         return list;
     } else {
         return ucx_list_append(list, regex);
--- a/dav/sync.c	Thu Aug 31 12:44:25 2017 +0200
+++ b/dav/sync.c	Thu Aug 31 12:55:09 2017 +0200
@@ -1001,13 +1001,7 @@
                     resources = ucx_list_append(resources, res);
                 }
             } else if(!sstrcmp(name, S("remove"))) {
-                LocalResource *res = calloc(1, sizeof(LocalResource));
-                res->path = sstrdup(value).ptr;
-                if(res) {
-                    //ucx_map_sstr_put(db->remove, value, res);
-                    ucx_map_sstr_remove(db->resources, value);
-                }
-                
+                ucx_map_sstr_remove(db->resources, value);
             }
             
             free(value.ptr);
--- a/libidav/davqlparser.c	Thu Aug 31 12:44:25 2017 +0200
+++ b/libidav/davqlparser.c	Thu Aug 31 12:55:09 2017 +0200
@@ -419,6 +419,7 @@
         ln, pn).ptr;
 }
 
+// TODO: this macro results in a memory leak - we return without freeing memory
 #define dqlsec_alloc_failed(ptr, stmt)                                  \
                     if (!(ptr)) {                                       \
                         (stmt)->errorcode = DAVQL_ERROR_OUT_OF_MEMORY;  \

mercurial