Skip to content

Commit

Permalink
extend-table: Fix a bug that iterates wrong table
Browse files Browse the repository at this point in the history
This seems to be a copy and paste bug that iterates and frees
the wrong table. This commit fixes that.

Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=10730
Co-authored-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
  • Loading branch information
yifsun and blp committed Oct 8, 2018
1 parent 2c02294 commit e7fc91d
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions ovn/lib/extend-table.c
Expand Up @@ -33,26 +33,25 @@ ovn_extend_table_init(struct ovn_extend_table *table)
hmap_init(&table->existing);
}

static void
ovn_extend_table_info_destroy(struct hmap *target)
{
struct ovn_extend_table_info *e, *next;
HMAP_FOR_EACH_SAFE (e, next, hmap_node, target) {
hmap_remove(target, &e->hmap_node);
free(e->name);
free(e);
}
hmap_destroy(target);
}

void
ovn_extend_table_destroy(struct ovn_extend_table *table)
{
bitmap_free(table->table_ids);

struct ovn_extend_table_info *desired, *d_next;
HMAP_FOR_EACH_SAFE (desired, d_next, hmap_node, &table->existing) {
hmap_remove(&table->existing, &desired->hmap_node);
free(desired->name);
free(desired);
}
hmap_destroy(&table->desired);

struct ovn_extend_table_info *existing, *e_next;
HMAP_FOR_EACH_SAFE (existing, e_next, hmap_node, &table->existing) {
hmap_remove(&table->existing, &existing->hmap_node);
free(existing->name);
free(existing);
}
hmap_destroy(&table->existing);
ovn_extend_table_info_destroy(&table->desired);
ovn_extend_table_info_destroy(&table->existing);
}

/* Finds and returns a group_info in 'existing' whose key is identical
Expand Down

0 comments on commit e7fc91d

Please sign in to comment.