Rev 1340: Fix some memory leaks. in http://people.samba.org/bzr/jelmer/bzr-svn/0.4
Jelmer Vernooij
jelmer at samba.org
Tue Jun 24 11:00:18 BST 2008
At http://people.samba.org/bzr/jelmer/bzr-svn/0.4
------------------------------------------------------------
revno: 1340
revision-id: jelmer at samba.org-20080624100017-idv4mum87h2g0g6e
parent: jelmer at samba.org-20080624094017-kxxown4f4euo5zje
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Tue 2008-06-24 12:00:17 +0200
message:
Fix some memory leaks.
modified:
ra.c ra.pyx-20080313140933-qybkqaxe3m4mcll7-1
repos.c repos.pyx-20080314114432-g2b5lqe776tkbl4k-1
util.c util.c-20080531154025-s8ef6ej9tytsnkkw-1
=== modified file 'ra.c'
--- a/ra.c 2008-06-24 01:56:05 +0000
+++ b/ra.c 2008-06-24 10:00:17 +0000
@@ -518,6 +518,7 @@
return py_svn_error();
*name = apr_pstrdup(pool, PyString_AsString(ret));
+ Py_DECREF(ret);
return NULL;
}
@@ -552,8 +553,10 @@
pool);
if (status) {
PyErr_SetAprStatus(status);
+ Py_DECREF(ret);
return NULL;
}
+ Py_DECREF(ret);
} else if (PyFile_Check(ret)) {
FILE *file;
apr_os_file_t osfile;
@@ -567,9 +570,14 @@
status = apr_os_file_put(fp, &osfile, O_CREAT | O_WRONLY, pool);
if (status) {
PyErr_SetAprStatus(status);
+ Py_DECREF(ret);
return NULL;
}
- }
+ } else {
+ PyErr_SetString(PyExc_TypeError, "Unknown type for file variable");
+ Py_DECREF(ret);
+ return NULL;
+ }
return NULL;
}
@@ -754,6 +762,7 @@
* so tweak our own parameters a bit. */
apr_paths = apr_array_make(temp_pool, 1, sizeof(char *));
APR_ARRAY_PUSH(apr_paths, char *) = apr_pstrdup(temp_pool, "");
+ apr_paths = NULL;
} else if (!string_list_to_apr_array(temp_pool, paths, &apr_paths)) {
apr_pool_destroy(temp_pool);
return NULL;
@@ -1774,6 +1783,7 @@
*cred = apr_pcalloc(pool, sizeof(**cred));
(*cred)->username = apr_pstrdup(pool, PyString_AsString(py_username));
(*cred)->may_save = (py_may_save == Py_True);
+ Py_DECREF(ret);
return NULL;
}
@@ -1832,6 +1842,7 @@
(*cred)->username = apr_pstrdup(pool, PyString_AsString(py_username));
(*cred)->password = apr_pstrdup(pool, PyString_AsString(py_password));
(*cred)->may_save = (py_may_save == Py_True);
+ Py_DECREF(ret);
return NULL;
}
@@ -1897,6 +1908,7 @@
(*cred)->accepted_failures = PyInt_AsLong(py_accepted_failures);
(*cred)->may_save = (py_may_save == Py_True);
+ Py_DECREF(ret);
return NULL;
}
@@ -1947,6 +1959,7 @@
*cred = apr_pcalloc(pool, sizeof(**cred));
(*cred)->password = apr_pstrdup(pool, PyString_AsString(py_password));
(*cred)->may_save = (py_may_save == Py_True);
+ Py_DECREF(ret);
return NULL;
}
@@ -1981,6 +1994,7 @@
*cred = apr_pcalloc(pool, sizeof(**cred));
(*cred)->cert_file = apr_pstrdup(pool, PyString_AsString(py_cert_file));
(*cred)->may_save = (py_may_save == Py_True);
+ Py_DECREF(ret);
return NULL;
}
=== modified file 'repos.c'
--- a/repos.c 2008-06-22 08:00:12 +0000
+++ b/repos.c 2008-06-24 10:00:17 +0000
@@ -48,7 +48,7 @@
pool = Pool(NULL);
if (pool == NULL)
return NULL;
- hash_config = apr_hash_make(pool); /* FIXME */
+ hash_config = config_hash_from_object(config, pool);
hash_fs_config = apr_hash_make(pool); /* FIXME */
RUN_SVN_WITH_POOL(pool, svn_repos_create(&repos, path, NULL, NULL,
hash_config, hash_fs_config, pool));
=== modified file 'util.c'
--- a/util.c 2008-06-24 02:17:21 +0000
+++ b/util.c 2008-06-24 10:00:17 +0000
@@ -190,6 +190,7 @@
Py_DECREF(revprops);
if (ret == NULL)
return py_svn_error();
+ Py_DECREF(ret);
return NULL;
}
#endif
@@ -221,6 +222,7 @@
Py_DECREF(revprops);
if (ret == NULL)
return py_svn_error();
+ Py_DECREF(ret);
return NULL;
}
@@ -264,6 +266,7 @@
/* FIXME: Handle !PyString_Check(ret) */
*length = PyString_Size(ret);
memcpy(buffer, PyString_AS_STRING(ret), *length);
+ Py_DECREF(ret);
return NULL;
}
@@ -273,6 +276,7 @@
ret = PyObject_CallMethod(self, "write", "s#", data, len[0]);
if (ret == NULL)
return py_svn_error();
+ Py_DECREF(ret);
return NULL;
}
@@ -283,6 +287,7 @@
if (ret == NULL)
return py_svn_error();
Py_DECREF(self);
+ Py_DECREF(ret);
return NULL;
}
@@ -303,8 +308,10 @@
if (py_fn != Py_None) {
PyObject *ret = PyObject_CallFunction(py_fn, NULL);
if (PyBool_Check(ret) && ret == Py_True) {
+ Py_DECREF(ret);
return svn_error_create(SVN_ERR_CANCELLED, NULL, NULL);
}
+ Py_DECREF(ret);
}
return NULL;
}
More information about the bazaar-commits
mailing list