]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
parser_json: Use xstrdup() when parsing rule comment
authorPhil Sutter <phil@nwl.cc>
Tue, 26 Feb 2019 21:13:40 +0000 (22:13 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 27 Feb 2019 10:25:14 +0000 (11:25 +0100)
Use xstrdup() instead of plain strdup() for consistency (and implicit
ENOMEM checking).

Fixes: 586ad210368b7 ("libnftables: Implement JSON parser")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/parser_json.c

index 78214f6519f2bd9b5a281a181c23a7a191ed7b12..6755d39c34f0adcbf56771bdc629444e069a8c10 100644 (file)
@@ -2461,7 +2461,7 @@ static struct cmd *json_parse_cmd_add_rule(struct json_ctx *ctx, json_t *root,
 
        json_unpack(root, "{s:s}", "comment", &comment);
        if (comment)
-               rule->comment = strdup(comment);
+               rule->comment = xstrdup(comment);
 
        json_array_foreach(tmp, index, value) {
                struct stmt *stmt;