From 54df179b10d4277a182f016f2c3faa8572209362 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Mon, 7 Sep 2009 12:05:10 +0300 Subject: [PATCH] Fix dumb some dumb leaks in python spec code --- python/spec-py.c | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/python/spec-py.c b/python/spec-py.c index 57b300d..0d17896 100644 --- a/python/spec-py.c +++ b/python/spec-py.c @@ -67,56 +67,44 @@ static PyObject * spec_get_prep(specObject * s) { rpmSpec spec = specFromSpec(s); + PyObject *res = NULL; if (spec != NULL && spec->prep) { - StringBuf sb = newStringBuf(); - sb=spec->prep; - return Py_BuildValue("s",getStringBuf(sb)); + res = Py_BuildValue("s",getStringBuf(spec->prep)); } - else { - return NULL; - } + return res; } static PyObject * spec_get_build(specObject * s) { rpmSpec spec = specFromSpec(s); + PyObject *res = NULL; if (spec != NULL && spec->build) { - StringBuf sb = newStringBuf(); - sb=spec->build; - return Py_BuildValue("s",getStringBuf(sb)); + res = Py_BuildValue("s",getStringBuf(spec->build)); } - else { - return NULL; - } + return res; } static PyObject * spec_get_install(specObject * s) { rpmSpec spec = specFromSpec(s); + PyObject *res = NULL; if (spec != NULL && spec->install) { - StringBuf sb = newStringBuf(); - sb=spec->install; - return Py_BuildValue("s",getStringBuf(sb)); + res = Py_BuildValue("s",getStringBuf(spec->install)); } - else { - return NULL; - } + return res; } static PyObject * spec_get_clean(specObject * s) { rpmSpec spec = specFromSpec(s); + PyObject *res = NULL; if (spec != NULL && spec->clean) { - StringBuf sb = newStringBuf(); - sb=spec->clean; - return Py_BuildValue("s",getStringBuf(sb)); + res = Py_BuildValue("s",getStringBuf(spec->clean)); } - else { - return NULL; - } + return res; } static PyObject * -- 2.7.4