[ovs-dev] [PATCHv2] ovsdb: Fix memory leak in execute_update.
William Tu
u9012063 at gmail.com
Mon Aug 1 17:03:55 UTC 2016
Valgrind testcase 1804 ovsdb-server.at:1023 insert rows, update rows by value
reports the following leak.
json_from_string (json.c:1025)
execute_update (replication.c:614), similarily at execute_delete()
process_table_update (replication.c:502)
process_notification.part.5 (replication.c:445)
process_notification (replication.c:402)
check_for_notifications (replication.c:418)
replication_run (replication.c:110)
Signed-off-by: William Tu <u9012063 at gmail.com>
---
v1->v2
* remove 'const' at struct json
---
ovsdb/replication.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/ovsdb/replication.c b/ovsdb/replication.c
index 463fa0a..e271425 100644
--- a/ovsdb/replication.c
+++ b/ovsdb/replication.c
@@ -547,7 +547,7 @@ static struct ovsdb_error *
execute_delete(struct ovsdb_txn *txn, const char *uuid,
struct ovsdb_table *table)
{
- const struct json *where;
+ struct json *where;
struct ovsdb_error *error;
struct ovsdb_condition condition = OVSDB_CONDITION_INITIALIZER(&condition);
char where_string[UUID_LEN+29];
@@ -571,6 +571,8 @@ execute_delete(struct ovsdb_txn *txn, const char *uuid,
}
ovsdb_condition_destroy(&condition);
+ json_destroy(where);
+
return error;
}
@@ -604,7 +606,7 @@ execute_update(struct ovsdb_txn *txn, const char *uuid,
struct update_row_cbdata ur;
struct ovsdb_row *row;
struct ovsdb_error *error;
- const struct json *where;
+ struct json *where;
char where_string[UUID_LEN+29];
snprintf(where_string, sizeof where_string, "%s%s%s",
@@ -628,6 +630,7 @@ execute_update(struct ovsdb_txn *txn, const char *uuid,
ovsdb_row_destroy(row);
ovsdb_column_set_destroy(&columns);
ovsdb_condition_destroy(&condition);
+ json_destroy(where);
return error;
}
--
2.5.0
More information about the dev
mailing list