diff options
author | Felix Fietkau <nbd@openwrt.org> | 2008-08-31 12:17:56 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2008-08-31 12:17:56 +0200 |
commit | f8cf80970bb8bd6e4c932b2cb14e57580e090488 (patch) | |
tree | df45931dd31eb90b17d4705b214f6bd287e475c0 | |
parent | 43124956bc9c1083e476f6cadaedf27b7788d004 (diff) | |
download | uci-f8cf80970bb8bd6e4c932b2cb14e57580e090488.tar.gz |
fix segfault in uci batch
-rw-r--r-- | util.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -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; |