From e438b9766fcc86d9847312ff05f1d1dac61acf1f Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Tue, 31 Aug 2021 12:29:43 +0200 Subject: nft: Use xtables_{m,c}alloc() everywhere Make use of libxtables allocators where sensible to have implicit error checking. Leave library-internal calls in place to not create unexpected program exit points for users, apart from xt_xlate_alloc() as that function called xtables_error() in error case which exits by itself already. Signed-off-by: Phil Sutter --- libxtables/xtables.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'libxtables') diff --git a/libxtables/xtables.c b/libxtables/xtables.c index b261e97b..d670175d 100644 --- a/libxtables/xtables.c +++ b/libxtables/xtables.c @@ -2353,18 +2353,11 @@ struct xt_xlate { struct xt_xlate *xt_xlate_alloc(int size) { - struct xt_xlate *xl; + struct xt_xlate *xl = xtables_malloc(sizeof(struct xt_xlate)); int i; - xl = malloc(sizeof(struct xt_xlate)); - if (xl == NULL) - xtables_error(RESOURCE_PROBLEM, "OOM"); - for (i = 0; i < __XT_XLATE_MAX; i++) { - xl->buf[i].data = malloc(size); - if (xl->buf[i].data == NULL) - xtables_error(RESOURCE_PROBLEM, "OOM"); - + xl->buf[i].data = xtables_malloc(size); xl->buf[i].data[0] = '\0'; xl->buf[i].size = size; xl->buf[i].rem = size; -- cgit v1.2.3