]> git.ipfire.org Git - pakfire.git/commitdiff
_pakfire: Do not allocate an empty array
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 5 Jul 2021 17:16:03 +0000 (17:16 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 5 Jul 2021 17:16:03 +0000 (17:16 +0000)
It is easier to check for NULL

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_pakfire/pakfire.c

index 8a815559625f131e84c976bf2d8c5dfdfa58f45d..de87c3e3584f5a649db0242305940163eace16ce 100644 (file)
@@ -221,6 +221,8 @@ static int convert_packages(PyObject* object, void* address) {
        }
 
        const unsigned int length = PySequence_Length(object);
+       if (!length)
+               return Py_CLEANUP_SUPPORTED;
 
        // Allocate array
        *packages = calloc(length + 1, sizeof(*packages));