From 0eee3009e7015b82a46b2eccad91f759d75ec4df Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Wed, 26 Nov 2008 17:18:08 +0100 Subject: libiptc: guard chain index allocation for different malloc implementations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- libiptc/libiptc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libiptc') 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; } -- cgit v1.2.3