X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=libecoli_yaml%2Fecoli_yaml.c;h=84007d55b96a756ff1d3f8c60b38b1bc908eff62;hb=7dfc4c9ed511c058b0ac47826742aec7b5175ecd;hp=850b414f89fc94a368f414f77afa29969732f420;hpb=a2ae9e1af72130262556e644730c6c721a93d1f2;p=protos%2Flibecoli.git diff --git a/libecoli_yaml/ecoli_yaml.c b/libecoli_yaml/ecoli_yaml.c index 850b414..84007d5 100644 --- a/libecoli_yaml/ecoli_yaml.c +++ b/libecoli_yaml/ecoli_yaml.c @@ -11,6 +11,9 @@ #include #include + +#include +#include #include #include #include @@ -214,6 +217,7 @@ parse_ec_config(struct enode_table *table, if (enode == NULL) goto fail; config = ec_config_node(enode); + enode = NULL; if (config == NULL) { fprintf(stderr, "Failed to create config\n"); goto fail; @@ -348,7 +352,8 @@ parse_ec_node(struct enode_table *table, { const struct ec_config_schema *schema; const struct ec_node_type *type = NULL; - const char *id = NULL, *help = NULL; + const char *id = NULL; + char *help = NULL; struct ec_config *config = NULL; const yaml_node_t *attrs = NULL; const yaml_node_t *key, *value; @@ -412,7 +417,11 @@ parse_ec_node(struct enode_table *table, fprintf(stderr, "Help must be a scalar\n"); goto fail; } - help = value_str; + help = ec_strdup(value_str); + if (help == NULL) { + fprintf(stderr, "Failed to allocate help\n"); + goto fail; + } } } @@ -442,9 +451,21 @@ parse_ec_node(struct enode_table *table, goto fail; if (ec_node_set_config(enode, config) < 0) { + config = NULL; /* freed */ fprintf(stderr, "Failed to set config\n"); goto fail; } + config = NULL; /* freed */ + + if (help != NULL) { + if (ec_keyval_set(ec_node_attrs(enode), "help", help, + ec_free_func) < 0) { + fprintf(stderr, "Failed to set help\n"); + help = NULL; + goto fail; + } + help = NULL; + } /* add attributes (all as string) */ //XXX @@ -454,6 +475,8 @@ parse_ec_node(struct enode_table *table, fail: ec_node_free(enode); ec_config_free(config); + ec_free(help); + return NULL; }