diff mbox series

[uci,1/2] file: Fix uci -m import command

Message ID 20230714182811.20444-2-jan@venekamp.net
State Accepted
Delegated to: Hauke Mehrtens
Headers show
Series remove internal usage of redundant uci_ptr.last | expand

Commit Message

Jan Venekamp July 14, 2023, 6:28 p.m. UTC
Without this change we see the following error:
  # uci -m import optic < /etc/optic-db/default
  uci: Parse error (option/list command found before the first section) at line 4, byte 1

ptr.last is still a null pointer in case the uci_lookup_list() call
found a matching section and set ptr.s to it. The code expects that
uci_set() updates the ptr.last pointer, but this is not done any more.
If case uci_lookup_list() did not found a section ptr->s is a null
pointer and then uci_set() will allocate a new section.

Fixes: ae61e1cad4a1 ("uci: optimize update section in uci_set")
Co-authored-by: Hauke Mehrtens <hmehrtens@maxlinear.com>
Signed-off-by: Jan Venekamp <jan@venekamp.net>
---
 file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/file.c b/file.c
index 93abfae..6610f53 100644
--- a/file.c
+++ b/file.c
@@ -459,7 +459,7 @@  static void uci_parse_config(struct uci_context *ctx)
 
 		ctx->internal = !pctx->merge;
 		UCI_NESTED(uci_set, ctx, &ptr);
-		pctx->section = uci_to_section(ptr.last);
+		pctx->section = ptr.s;
 	}
 }