]> git.ipfire.org Git - people/stevee/pakfire.git/commitdiff
python: execute: Fix SEGV when no output has been returned
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 17 Aug 2022 08:59:58 +0000 (08:59 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 17 Aug 2022 08:59:58 +0000 (08:59 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_pakfire/pakfire.c

index 702ed88dc49ac392857a512052901530e3ac9bf2..49230294f26d7e052ed777689589729353d55fa0 100644 (file)
@@ -964,10 +964,12 @@ static PyObject* Pakfire_execute(PakfireObject* self, PyObject* args, PyObject*
        // Did the user request the output?
        if (return_output) {
                // Return the buffer as bytes
-               ret = PyBytes_FromString(output);
+               if (output)
+                       ret = PyBytes_FromString(output);
+       }
 
        // Otherwise just return None
-       } else {
+       if (!ret) {
                ret = Py_None;
                Py_INCREF(ret);
        }