Issue
=====
When initializing a `flt.lttng-utils.debug-info` message iterator,
errors may occur before the initialization of the iterator's
`bt_fd_cache`. If that occurs, the iterator is destroyed using the
`debug_info_msg_iter_destroy()` function which calls the
`bt_fd_cache_fini()` function. Leading to the `fdc->cache` being NULL
and thus triggering an assertion failure.
Solution
========
Change the `BT_ASSERT()` to an early return.
Drawbacks
=========
None.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ib6abd595f1c4365836cacd0357c7323f0b4c6385
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2044
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
BT_HIDDEN
void bt_fd_cache_fini(struct bt_fd_cache *fdc)
{
- BT_ASSERT(fdc->cache);
+ if (!fdc->cache) {
+ goto end;
+ }
+
/*
* All handle should have been removed for the hashtable at this point.
*/
BT_ASSERT(g_hash_table_size(fdc->cache) == 0);
g_hash_table_destroy(fdc->cache);
+end:
return;
}