Various fixes for memory leaks/potential error conditions.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 19 Sep 2011 21:42:51 +0000 (23:42 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 19 Sep 2011 21:42:51 +0000 (23:42 +0200)
subvertpy/client.c
subvertpy/repos.c
subvertpy/wc.c

index 1f8645e1d56ff81d082f6e2497d83bf4de731c6e..597119deaaae7c6fc02d73d9a7cc2f676622fab0 100644 (file)
@@ -1470,8 +1470,10 @@ static PyObject *get_config(PyObject *self, PyObject *args)
         return NULL;
 
     data->pool = Pool(NULL);
-    if (data->pool == NULL)
+    if (data->pool == NULL) {
+        PyObject_Del(data);
         return NULL;
+    }
 
     RUN_SVN_WITH_POOL(data->pool, 
                       svn_config_get_config(&data->config, config_dir, data->pool));
index 885999c42e723c83b3257d897cc0b41507c0d5ea..603059531ab0e93ae2697804e8e7a95149d7a491 100644 (file)
@@ -53,9 +53,11 @@ static PyObject *repos_create(PyObject *self, PyObject *args)
        if (pool == NULL)
                return NULL;
     hash_config = config_hash_from_object(config, pool);
-       if (hash_config == NULL)
+       if (hash_config == NULL) {
+               apr_pool_destroy(pool);
                return NULL;
-    hash_fs_config = apr_hash_make(pool); /* FIXME */
+       }
+       hash_fs_config = apr_hash_make(pool); /* FIXME */
        if (hash_fs_config == NULL) {
                PyErr_SetString(PyExc_RuntimeError, "Unable to create fs config hash");
                return NULL;
index 94631b34a03e6130bc5937e986bdf1578470b82b..204f74cdebca31c7fdf54944863d73cdb8874808 100644 (file)
@@ -842,7 +842,7 @@ static PyObject *adm_get_prop_diffs(PyObject *self, PyObject *args)
        temp_pool = Pool(NULL);
        if (temp_pool == NULL)
                return NULL;
-       RUN_SVN_WITH_POOL(temp_pool, svn_wc_get_prop_diffs(&propchanges, &original_props, 
+       RUN_SVN_WITH_POOL(temp_pool, svn_wc_get_prop_diffs(&propchanges, &original_props,
                                svn_path_canonicalize(path, temp_pool), admobj->adm, temp_pool));
        py_propchanges = PyList_New(propchanges->nelts);
        if (py_propchanges == NULL) {
@@ -856,15 +856,22 @@ static PyObject *adm_get_prop_diffs(PyObject *self, PyObject *args)
                else
                        pyval = Py_BuildValue("(sO)", el.name, Py_None);
                if (pyval == NULL) {
+                       apr_pool_destroy(temp_pool);
+                       Py_DECREF(py_propchanges);
+                       return NULL;
+               }
+               if (!PyList_SetItem(py_propchanges, i, pyval)) {
+                       Py_DECREF(py_propchanges);
                        apr_pool_destroy(temp_pool);
                        return NULL;
                }
-               PyList_SetItem(py_propchanges, i, pyval);
        }
        py_orig_props = prop_hash_to_dict(original_props);
        apr_pool_destroy(temp_pool);
-       if (py_orig_props == NULL)
+       if (py_orig_props == NULL) {
+               Py_DECREF(py_propchanges);
                return NULL;
+       }
        return Py_BuildValue("(NN)", py_propchanges, py_orig_props);
 }