summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2022-01-15 18:50:21 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2022-01-15 18:50:21 +0100
commit71ae4e960357516c655bda9495db17bc0abea5b3 (patch)
tree744860a4eb6c80f92c8a1141f9421cfc0d669e4e /src
parent57291e35fcf6dbbc2fb0bd6b0465a9a82b66eb93 (diff)
libnftables: use xrealloc()
Instead of realloc(), so process stops execution in case memory allocation fails. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r--src/libnftables.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/libnftables.c b/src/libnftables.c
index bd71ae9e..dc0932bd 100644
--- a/src/libnftables.c
+++ b/src/libnftables.c
@@ -128,9 +128,7 @@ int nft_ctx_add_var(struct nft_ctx *ctx, const char *var)
if (!separator)
return -1;
- tmp = realloc(ctx->vars, (pcount + 1) * sizeof(struct nft_vars));
- if (!tmp)
- return -1;
+ tmp = xrealloc(ctx->vars, (pcount + 1) * sizeof(struct nft_vars));
*separator = '\0';
value = separator + 1;
@@ -162,9 +160,7 @@ int nft_ctx_add_include_path(struct nft_ctx *ctx, const char *path)
char **tmp;
int pcount = ctx->num_include_paths;
- tmp = realloc(ctx->include_paths, (pcount + 1) * sizeof(char *));
- if (!tmp)
- return -1;
+ tmp = xrealloc(ctx->include_paths, (pcount + 1) * sizeof(char *));
ctx->include_paths = tmp;
@@ -465,7 +461,7 @@ static char *stdin_to_buffer(void)
consumed += numbytes;
if (consumed == bufsiz) {
bufsiz *= 2;
- buf = realloc(buf, bufsiz);
+ buf = xrealloc(buf, bufsiz);
}
numbytes = read(STDIN_FILENO, buf + consumed, bufsiz - consumed);
}