X-Git-Url: http://pilppa.org/gitweb/?p=libplp.git;a=blobdiff_plain;f=src%2Fconfig.c;h=df77e3b236b3660b7658a2945e82c92786365d2a;hp=c099d97fbe022b89c12b0549667210427b38c987;hb=45dab65b4663bd3a4115d62effd430441e43fa23;hpb=e637096f7b0a1d73c07ff08d342a6eb2fda2b92e diff --git a/src/config.c b/src/config.c index c099d97..df77e3b 100644 --- a/src/config.c +++ b/src/config.c @@ -26,12 +26,15 @@ static int uci_create_named_section(struct uci_context *ctx, const char *conf_fi len = len + strlen(section_name); len = len + 1; cmd_data = malloc(len); - snprintf(cmd_data, len, "%s.%s=%s", conf_file_name, section_name, section_type); - if (uci_lookup_ptr(ctx, &ptr, cmd_data, true) == UCI_OK) { - ret_val = uci_set(ctx, &ptr); - if (ret_val == UCI_OK) { - //ret_val = uci_save(ctx, ptr.p); + if (cmd_data != NULL) { + snprintf(cmd_data, len, "%s.%s=%s", conf_file_name, section_name, section_type); + if (uci_lookup_ptr(ctx, &ptr, cmd_data, true) == UCI_OK) { + ret_val = uci_set(ctx, &ptr); + if (ret_val == UCI_OK) { + //ret_val = uci_save(ctx, ptr.p); + } } + free(cmd_data); } } return ret_val; @@ -114,7 +117,7 @@ bool set_config_value(const char *conf_dir_name, ptr.option = key; if (uci_lookup_ptr(ctx, &ptr, NULL, false) == UCI_OK) { - ptr.value = strdup(value); + ptr.value = value; uci_set(ctx, &ptr); save = true; }