Fix: flt.utils.muxer: don't clear an empty `GPtrArray`
authorMichael Jeanson <mjeanson@efficios.com>
Fri, 19 Jul 2019 19:14:45 +0000 (15:14 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Sat, 20 Jul 2019 13:39:32 +0000 (09:39 -0400)
GLib < 2.48.0 asserts when clearing an empty `GPtrArray` with
g_array_remove_range():

    GLib-CRITICAL **: g_ptr_array_remove_range: assertion
    `index_ < array->len' failed

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: If9dad0869404ec72ee15724b72ad88780b671619
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1725
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/plugins/utils/muxer/muxer.c

index e68c372c0addaa43615c152abbe894a785af702b..9510d07a5e45a865d33f7855fbdc02534f384268 100644 (file)
@@ -1531,8 +1531,14 @@ bt_component_class_message_iterator_seek_beginning_method_status muxer_msg_iter_
                muxer_msg_iter->ended_muxer_upstream_msg_iters->pdata[i] = NULL;
        }
 
-       g_ptr_array_remove_range(muxer_msg_iter->ended_muxer_upstream_msg_iters,
-               0, muxer_msg_iter->ended_muxer_upstream_msg_iters->len);
+       /*
+        * GLib < 2.48.0 asserts when g_ptr_array_remove_range() is
+        * called on an empty array.
+        */
+       if (muxer_msg_iter->ended_muxer_upstream_msg_iters->len > 0) {
+               g_ptr_array_remove_range(muxer_msg_iter->ended_muxer_upstream_msg_iters,
+                       0, muxer_msg_iter->ended_muxer_upstream_msg_iters->len);
+       }
        muxer_msg_iter->last_returned_ts_ns = INT64_MIN;
        muxer_msg_iter->clock_class_expectation =
                MUXER_MSG_ITER_CLOCK_CLASS_EXPECTATION_ANY;
This page took 0.028777 seconds and 4 git commands to generate.