X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fplugins%2Fctf%2Fcommon%2Fmsg-iter%2Fmsg-iter.cpp;h=5f38ec6c0dd5ebdac1397e228086d07558d7840b;hb=839df1da87b7bdaac5ebfd4e798ea769a94843b2;hp=4efc5ed61b9b6e6786750cbed3461cd3a1f40d6d;hpb=89ec984ed8142a2cd79603e8d7b26544fc17d2a7;p=babeltrace.git diff --git a/src/plugins/ctf/common/msg-iter/msg-iter.cpp b/src/plugins/ctf/common/msg-iter/msg-iter.cpp index 4efc5ed6..5f38ec6c 100644 --- a/src/plugins/ctf/common/msg-iter/msg-iter.cpp +++ b/src/plugins/ctf/common/msg-iter/msg-iter.cpp @@ -1793,6 +1793,20 @@ end: msg_it->default_clock_snapshot); } +/* + * Ensure the message iterator's `stored_values` array is large enough to + * accomodate `storing_index`. + * + * We may need more slots in the array than initially allocated if more + * metadata arrives along the way. + */ +static void ensure_stored_values_size(ctf_msg_iter *msg_it, uint64_t storing_index) +{ + if (G_UNLIKELY(storing_index >= msg_it->stored_values->len)) { + g_array_set_size(msg_it->stored_values, msg_it->meta.tc->stored_value_count); + } +} + static enum bt_bfcr_status bfcr_unsigned_int_cb(uint64_t value, struct ctf_field_class *fc, void *data) { @@ -1862,6 +1876,7 @@ update_def_clock: } if (G_UNLIKELY(int_fc->storing_index >= 0)) { + ensure_stored_values_size(msg_it, int_fc->storing_index); bt_g_array_index(msg_it->stored_values, uint64_t, (uint64_t) int_fc->storing_index) = value; } @@ -1948,6 +1963,7 @@ static enum bt_bfcr_status bfcr_signed_int_cb(int64_t value, struct ctf_field_cl BT_ASSERT_DBG(int_fc->meaning == CTF_FIELD_CLASS_MEANING_NONE); if (G_UNLIKELY(int_fc->storing_index >= 0)) { + ensure_stored_values_size(msg_it, int_fc->storing_index); bt_g_array_index(msg_it->stored_values, uint64_t, (uint64_t) int_fc->storing_index) = (uint64_t) value; }