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

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