}
if (!ti) {
ti = malloc(sizeof(struct uci_type_list));
+ if (!ti)
+ return NULL;
memset(ti, 0, sizeof(struct uci_type_list));
ti->next = type_list;
type_list = ti;
} else {
typestr = realloc(typestr, maxlen);
}
- sprintf(typestr, "@%s[%d]", ti->name, ti->idx);
+
+ if (typestr)
+ sprintf(typestr, "@%s[%d]", ti->name, ti->idx);
+
ti->idx++;
+
return typestr;
}
/*
* 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) {