Coverity reported the following:
CID
1401187 (#1 of 1): Dereference before null check
(REVERSE_INULL)check_after_deref: Null-checking pool suggests that it
may be null, but it has already been dereferenced on all paths leading
to the check.
Add a `BT_ASSERT()` to ensure that `pool` is not null.
Reported-by: Coverity - 1401187 Dereference before null check (REVERSE_INULL)
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ie18fecdad17c1a42db914d2eb987f783a4523871
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2054
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
{
int ret = 0;
+ BT_ASSERT(pool);
BT_ASSERT(new_object_func);
BT_ASSERT(destroy_object_func);
BT_LOGD("Initializing object pool: addr=%p, data-addr=%p",
goto end;
error:
- if (pool) {
- bt_object_pool_finalize(pool);
- }
-
+ bt_object_pool_finalize(pool);
ret = -1;
end: