]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: use malloc() and free() from cli and main
authorPablo Neira Ayuso <pablo@netfilter.org>
Thu, 4 Jul 2019 12:38:37 +0000 (14:38 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 4 Jul 2019 22:42:56 +0000 (00:42 +0200)
xmalloc() and xfree() are internal symbols of the library, do not use
them.

Fixes: 16543a0136c0 ("libnftables: export public symbols only")
Reported-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/cli.c
src/main.c

index ca3869abe335fc25e01e384964c56f169e456503..bbdd0fdbeeb8c5166b2d0be56bd654b9c1f15a96 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -63,9 +63,15 @@ static char *cli_append_multiline(char *line)
                rl_set_prompt(".... ");
        } else {
                len += strlen(multiline);
-               s = xmalloc(len + 1);
+               s = malloc(len + 1);
+               if (!s) {
+                       fprintf(stderr, "%s:%u: Memory allocation failure\n",
+                               __FILE__, __LINE__);
+                       cli_exit();
+                       exit(EXIT_FAILURE);
+               }
                snprintf(s, len + 1, "%s%s", multiline, line);
-               xfree(multiline);
+               free(multiline);
                multiline = s;
        }
        line = NULL;
@@ -111,7 +117,7 @@ static void cli_complete(char *line)
                add_history(line);
 
        nft_run_cmd_from_buffer(cli_nft, line);
-       xfree(line);
+       free(line);
 }
 
 static char **cli_completion(const char *text, int start, int end)
index 8e6c897cdd36c9fca5e566f542bfa5a09e0f02e6..694611224d07f8ba36b4786fb5a5a3766a3c7a47 100644 (file)
@@ -329,7 +329,7 @@ int main(int argc, char * const *argv)
                exit(EXIT_FAILURE);
        }
 
-       xfree(buf);
+       free(buf);
        nft_ctx_free(nft);
 
        return rc;