X-Git-Url: https://git.archive.openwrt.org/?a=blobdiff_plain;ds=sidebyside;f=util.c;h=177bd1408d3fa24ce4a33b38917644b9e6bfa632;hb=e9b46ce12d4ab204cd4a13999c0e04107c8f7d7d;hp=7f37e882fc5348bc1254de3a87f6473d95d2f485;hpb=8500c9b01699a94c0516ee5cbc10e8c0fb7b0408;p=project%2Fuci.git diff --git a/util.c b/util.c index 7f37e88..177bd14 100644 --- a/util.c +++ b/util.c @@ -398,14 +398,14 @@ int uci_parse_argument(struct uci_context *ctx, FILE *stream, char **str, char * UCI_ASSERT(ctx, str != NULL); UCI_ASSERT(ctx, result != NULL); - if (ctx->pctx) { - if (ctx->pctx->file != stream) { - uci_cleanup(ctx); - } - } else { + if (ctx->pctx && (ctx->pctx->file != stream)) + uci_cleanup(ctx); + + if (!ctx->pctx) uci_alloc_parse_context(ctx); - ctx->pctx->file = stream; - } + + ctx->pctx->file = stream; + if (!*str) { uci_getln(ctx, 0); *str = ctx->pctx->buf;