ovsdb-tool: Fix segfault if deleted row doesn't exist.
authorBen Pfaff <blp@nicira.com>
Mon, 15 Mar 2010 21:50:14 +0000 (14:50 -0700)
committerBen Pfaff <blp@nicira.com>
Wed, 17 Mar 2010 21:24:55 +0000 (14:24 -0700)
This "can't happen" normally, but it will if you monkey with the OVSDB
file by hand such that a row that gets deleted never actually existed in
the db.

ovsdb/ovsdb-tool.c

index b2e200c..dedc179 100644 (file)
@@ -337,8 +337,13 @@ print_db_changes(struct shash *tables, struct shash *names)
                                                 : xmemdup0(row_uuid, 8)));
                 }
             } else if (columns->type == JSON_NULL) {
+                struct shash_node *node;
+
                 printf("\t\tdelete row\n");
-                shash_delete(names, shash_find(names, row_uuid));
+                node = shash_find(names, row_uuid);
+                if (node) {
+                    shash_delete(names, node);
+                }
                 free(old_name);
             }