From 1248fcd24a6870460441aadcf2039c86dfea0af6 Mon Sep 17 00:00:00 2001
From: Ben Pfaff <blp@nicira.com>
Date: Fri, 6 Nov 2009 13:36:41 -0800
Subject: [PATCH] ovsdb: Fix use-after-free error in ovsdb_destroy().

---
 ovsdb/ovsdb.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/ovsdb/ovsdb.c b/ovsdb/ovsdb.c
index e653758fd..1a4b6d8da 100644
--- a/ovsdb/ovsdb.c
+++ b/ovsdb/ovsdb.c
@@ -245,9 +245,10 @@ ovsdb_destroy(struct ovsdb *db)
         }
         shash_destroy(&db->tables);
 
-        /* Clear the schema's hash of table schemas.  The schemas, but not the
-         * table that points to them, were deleted in the previous step. */
-        shash_destroy(&db->schema->tables);
+        /* The schemas, but not the table that points to them, were deleted in
+         * the previous step, so we need to clear out the table.  We can't
+         * destroy the table, because ovsdb_schema_destroy() will do that. */
+        shash_clear(&db->schema->tables);
 
         ovsdb_schema_destroy(db->schema);
         ovsdb_file_close(db->file);
-- 
2.47.0