From: Jan Engelhardt Date: Wed, 26 Nov 2008 16:18:08 +0000 (+0100) Subject: libiptc: guard chain index allocation for different malloc implementations X-Git-Tag: v1.4.3~65 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0eee3009e7015b82a46b2eccad91f759d75ec4df;p=thirdparty%2Fiptables.git libiptc: guard chain index allocation for different malloc implementations 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 Signeed-off-by: Patrick McHardy --- diff --git a/libiptc/libiptc.c b/libiptc/libiptc.c index 13e4c69f..544a5b29 100644 --- a/libiptc/libiptc.c +++ b/libiptc/libiptc.c @@ -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; }