When parsing a column fails (either ovsdb_parser_destroy() or ovsdb_type_from_json() returns an error), the partially-built columns shash and its ovsdb_type entries were leaked because the error path only frees tables already added to the schema.
Fix by adding columns to the schema immediately after creation, so ovsdb_cs_free_schema() in the error path cleans it up along with any types already parsed. Found by OpenScanHub Coverity (RESOURCE_LEAK). Signed-off-by: Timothy Redaelli <[email protected]> --- lib/ovsdb-cs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ovsdb-cs.c b/lib/ovsdb-cs.c index df33a835d..3920c2e5c 100644 --- a/lib/ovsdb-cs.c +++ b/lib/ovsdb-cs.c @@ -2140,6 +2140,7 @@ ovsdb_cs_parse_schema(const struct json *schema_json) struct shash *columns = xmalloc(sizeof *columns); shash_init(columns); + shash_add(schema, table_name, columns); struct shash_node *node2; SHASH_FOR_EACH (node2, json_object(columns_json)) { @@ -2170,7 +2171,6 @@ ovsdb_cs_parse_schema(const struct json *schema_json) free(type); } } - shash_add(schema, table_name, columns); } return schema; -- 2.54.0 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
