projects
/
project
/
uci.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
lua: expose add_list change items as table values
[project/uci.git]
/
cli.c
diff --git
a/cli.c
b/cli.c
index
b660273
..
196a83e
100644
(file)
--- a/
cli.c
+++ b/
cli.c
@@
-98,6
+98,8
@@
uci_lookup_section_ref(struct uci_section *s)
}
if (!ti) {
ti = malloc(sizeof(struct uci_type_list));
}
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;
memset(ti, 0, sizeof(struct uci_type_list));
ti->next = type_list;
type_list = ti;
@@
-110,8
+112,12
@@
uci_lookup_section_ref(struct uci_section *s)
} else {
typestr = realloc(typestr, maxlen);
}
} 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++;
ti->idx++;
+
return typestr;
}
return typestr;
}
@@
-444,7
+450,7
@@
static int uci_do_section_cmd(int cmd, int argc, char **argv)
ret = uci_add_list(ctx, &ptr);
break;
case CMD_REORDER:
ret = uci_add_list(ctx, &ptr);
break;
case CMD_REORDER:
- if (!ptr.s) {
+ if (!ptr.s
|| !ptr.value
) {
ctx->err = UCI_ERR_NOTFOUND;
cli_perror();
return 1;
ctx->err = UCI_ERR_NOTFOUND;
cli_perror();
return 1;
@@
-627,6
+633,11
@@
int main(int argc, char **argv)
delimiter = optarg;
break;
case 'f':
delimiter = optarg;
break;
case 'f':
+ if (input != stdin) {
+ perror("uci");
+ return 1;
+ }
+
input = fopen(optarg, "r");
if (!input) {
perror("uci");
input = fopen(optarg, "r");
if (!input) {
perror("uci");