name = next_arg(ctx, str, false, true);
assert_eol(ctx, str);
- if (!name) {
+ if (!name || !name[0]) {
ctx->internal = !pctx->merge;
UCI_NESTED(uci_add_section, ctx, pctx->package, type, &pctx->section);
} else {
/*
* escape an uci string for export
*/
-static char *uci_escape(struct uci_context *ctx, const char *str)
+static const char *uci_escape(struct uci_context *ctx, const char *str)
{
const char *end;
int ofs = 0;
if (!ctx->buf) {
ctx->bufsz = LINEBUF;
ctx->buf = malloc(LINEBUF);
+
+ if (!ctx->buf)
+ return str;
}
while (1) {
uci_alloc_parse_context(ctx);
pctx = ctx->pctx;
pctx->file = stream;
- if (*package && single) {
+ if (package && *package && single) {
pctx->package = *package;
pctx->merge = true;
}