file: fix segfault in uci_parse_option
[project/uci.git] / file.c
diff --git a/file.c b/file.c
index f5032bd12847fc8ebdd6132d2293803aefe4aad0..3ac49c6edaf31eb081e805329605adc05502cf4d 100644 (file)
--- a/file.c
+++ b/file.c
@@ -425,9 +425,9 @@ static void uci_parse_config(struct uci_context *ctx)
                uci_parse_error(ctx, "invalid character in type field");
 
        ofs_name = next_arg(ctx, false, true, false);
+       assert_eol(ctx);
        type = pctx_str(pctx, ofs_type);
        name = pctx_str(pctx, ofs_name);
-       assert_eol(ctx);
 
        if (!name || !name[0]) {
                ctx->internal = !pctx->merge;
@@ -471,9 +471,9 @@ static void uci_parse_option(struct uci_context *ctx, bool list)
 
        ofs_name = next_arg(ctx, true, true, false);
        ofs_value = next_arg(ctx, false, false, false);
+       assert_eol(ctx);
        name = pctx_str(pctx, ofs_name);
        value = pctx_str(pctx, ofs_value);
-       assert_eol(ctx);
 
        uci_fill_ptr(ctx, &ptr, &pctx->section->e);
        e = uci_lookup_list(&pctx->section->options, name);