Blame SOURCES/0015-json-init-parser-state-for-every-new-buffer-file.patch

195495
From 27f931c935f27a00fe0ecbe8c4bcb3be6ba41096 Mon Sep 17 00:00:00 2001
195495
From: Eric Garver <eric@garver.life>
195495
Date: Fri, 19 Feb 2021 10:11:26 -0500
195495
Subject: [PATCH] json: init parser state for every new buffer/file
195495
195495
Otherwise invalid error states cause subsequent json parsing to fail
195495
when it should not.
195495
195495
Signed-off-by: Eric Garver <eric@garver.life>
195495
Signed-off-by: Phil Sutter <phil@nwl.cc>
195495
(cherry picked from commit 267338ec392346ef55ed51509e5f8e8354d6c19a)
195495
---
195495
 src/parser_json.c | 2 ++
195495
 1 file changed, 2 insertions(+)
195495
195495
diff --git a/src/parser_json.c b/src/parser_json.c
195495
index 85d05ce27eef3..9bba77dad5f0d 100644
195495
--- a/src/parser_json.c
195495
+++ b/src/parser_json.c
195495
@@ -3893,6 +3893,7 @@ int nft_parse_json_buffer(struct nft_ctx *nft, const char *buf,
195495
 	};
195495
 	int ret;
195495
 
195495
+	parser_init(nft, nft->state, msgs, cmds, nft->top_scope);
195495
 	nft->json_root = json_loads(buf, 0, NULL);
195495
 	if (!nft->json_root)
195495
 		return -EINVAL;
195495
@@ -3921,6 +3922,7 @@ int nft_parse_json_filename(struct nft_ctx *nft, const char *filename,
195495
 	json_error_t err;
195495
 	int ret;
195495
 
195495
+	parser_init(nft, nft->state, msgs, cmds, nft->top_scope);
195495
 	nft->json_root = json_load_file(filename, 0, &err;;
195495
 	if (!nft->json_root)
195495
 		return -EINVAL;
195495
-- 
195495
2.31.1
195495