🧪 test(plug_mgr): test case add emptpy toml

This commit is contained in:
yangwei
2024-09-13 16:21:16 +08:00
parent e9825c3988
commit fb32deec1d
4 changed files with 22 additions and 11 deletions

View File

@@ -38,10 +38,11 @@ static struct plugin_specific *plugin_specs_load(const char *toml_conf_path, int
fprintf(stderr, "Error parsing toml: %s\n", errbuf);
return NULL;
}
struct plugin_specific* plugins=NULL;
toml_array_t* plugin_array = toml_array_in(conf, "plugin");
if(plugin_array==NULL)return NULL;
if(plugin_array==NULL)goto PLUGIN_SPEC_LOAD_ERROR;
*spec_num = toml_array_nelem(plugin_array);
struct plugin_specific* plugins = CALLOC(struct plugin_specific, *spec_num);
plugins = CALLOC(struct plugin_specific, *spec_num);
for (int i = 0; i < *spec_num; i++) {
toml_table_t* plugin = toml_table_at(plugin_array, i);
@@ -80,7 +81,7 @@ static struct plugin_specific *plugin_specs_load(const char *toml_conf_path, int
return plugins;
PLUGIN_SPEC_LOAD_ERROR:
toml_free(conf);
FREE(plugins);
if(plugins)FREE(plugins);
return NULL;
}