summaryrefslogtreecommitdiffstats
path: root/libxtables
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2021-08-31 12:29:43 +0200
committerPhil Sutter <phil@nwl.cc>2021-08-31 18:19:04 +0200
commite438b9766fcc86d9847312ff05f1d1dac61acf1f (patch)
tree2a7a550cd343caadb67a2e2331d533c56dc0f4da /libxtables
parentca11c7b7036b5821c17b8d08dc2a29f55b461a93 (diff)
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 <phil@nwl.cc>
Diffstat (limited to 'libxtables')
-rw-r--r--libxtables/xtables.c11
1 files changed, 2 insertions, 9 deletions
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;