[arch-projects] [pyalpm][PATCH v2] free log when it's no longer required

Jelle van der Waa jelle at vdwaa.nl
Tue Oct 11 08:32:32 UTC 2016


Valgrind indicated that 253,052 bytes where definitely lost when running
lsoptdepends. Valgrind reports before and after:

- definitely lost: 253,052 bytes in 4,979 blocks
- definitely lost: 48 bytes in 2 blocks

Signed-off-by: Jelle van der Waa <jelle at vdwaa.nl>
---

Changes since v2:
 * Check if vasprintf allocated memory.

 src/options.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/options.c b/src/options.c
index 0dad965..2637c9d 100644
--- a/src/options.c
+++ b/src/options.c
@@ -340,6 +340,7 @@ void pyalpm_logcb(alpm_loglevel_t level, const char *fmt, va_list va_args) {
   if(ret == -1)
     log = "pyalpm_logcb: could not allocate memory";
   result = PyObject_CallFunction(global_py_callbacks[CB_LOG], "is", level, log);
+  if (ret != -1) free(log);
   if (!result) PyErr_Print();
   Py_CLEAR(result);
 }
-- 
2.10.0


More information about the arch-projects mailing list