]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
libiptc: guard chain index allocation for different malloc implementations
authorJan Engelhardt <jengelh@medozas.de>
Wed, 26 Nov 2008 16:18:08 +0000 (17:18 +0100)
committerPatrick McHardy <kaber@trash.net>
Wed, 26 Nov 2008 16:18:08 +0000 (17:18 +0100)
Some libc implementations such as ÂµClibc return NULL on malloc(0).
They are free to do that per C standard.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
Signeed-off-by: Patrick McHardy <kaber@trash.net>
libiptc/libiptc.c

index 13e4c69f9e44ec521eeabbf97b74c4bffe27fad8..544a5b294064d365997aad67af640ea1a087ec02 100644 (file)
@@ -503,7 +503,7 @@ static int iptcc_chain_index_alloc(struct xtc_handle *h)
              array_elems, array_mem);
 
        h->chain_index = malloc(array_mem);
-       if (!h->chain_index) {
+       if (h->chain_index == NULL && array_mem > 0) {
                h->chain_index_sz = 0;
                return -ENOMEM;
        }