This commit adds null pointer checks in some code that performs some decisions based on old and new input ovsdb_rows. The corresponding non-null assertion and early return are added if both the old and the new ovsdb_rows are NULL.
Signed-off-by: James Raphael Tiovalen <[email protected]> --- ovsdb/file.c | 21 +++++++++++++++++---- ovsdb/monitor.c | 19 +++++++++++++++++-- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/ovsdb/file.c b/ovsdb/file.c index 2d887e53e..498c73127 100644 --- a/ovsdb/file.c +++ b/ovsdb/file.c @@ -522,9 +522,16 @@ ovsdb_file_txn_add_row(struct ovsdb_file_txn *ftxn, } if (row) { - struct ovsdb_table *table = new ? new->table : old->table; + struct ovsdb_table *table = NULL; + if (new) { + table = new->table; + } else if (old) { + table = old->table; + } char uuid[UUID_LEN + 1]; + ovs_assert(table); + if (table != ftxn->table) { /* Create JSON object for transaction overall. */ if (!ftxn->json) { @@ -538,9 +545,15 @@ ovsdb_file_txn_add_row(struct ovsdb_file_txn *ftxn, } /* Add row to transaction for this table. */ - snprintf(uuid, sizeof uuid, - UUID_FMT, UUID_ARGS(ovsdb_row_get_uuid(new ? new : old))); - json_object_put(ftxn->table_json, uuid, row); + if (new) { + snprintf(uuid, sizeof uuid, + UUID_FMT, UUID_ARGS(ovsdb_row_get_uuid(new))); + json_object_put(ftxn->table_json, uuid, row); + } else if (old) { + snprintf(uuid, sizeof uuid, + UUID_FMT, UUID_ARGS(ovsdb_row_get_uuid(old))); + json_object_put(ftxn->table_json, uuid, row); + } } } diff --git a/ovsdb/monitor.c b/ovsdb/monitor.c index 4a0d6512f..34f5e041f 100644 --- a/ovsdb/monitor.c +++ b/ovsdb/monitor.c @@ -1330,8 +1330,23 @@ ovsdb_monitor_changes_update(const struct ovsdb_row *old, const struct ovsdb_monitor_table *mt, struct ovsdb_monitor_change_set_for_table *mcst) { - const struct uuid *uuid = ovsdb_row_get_uuid(new ? new : old); - struct ovsdb_monitor_row *change; + const struct uuid *uuid = NULL; + + if (!new && !old) { + return; + } else { + if (new) { + uuid = ovsdb_row_get_uuid(new); + } else if (old) { + uuid = ovsdb_row_get_uuid(old); + } + } + + if (!uuid) { + return; + } + + struct ovsdb_monitor_row *change = NULL; change = ovsdb_monitor_changes_row_find(mcst, uuid); if (!change) { -- 2.40.0 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
