X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=lib%2Fctf-ir%2Fattributes.c;h=b5fe54cd45ca61a034bd259e52ffd4c76ded11b6;hb=8b45963bc7e8fa499b97079008156a51c35bba86;hp=f3d6ba10e8806d3757035d1637f6df0e2b1a66d4;hpb=d244c559056c44c46916e4799b1c6fa6311484fa;p=babeltrace.git diff --git a/lib/ctf-ir/attributes.c b/lib/ctf-ir/attributes.c index f3d6ba10..b5fe54cd 100644 --- a/lib/ctf-ir/attributes.c +++ b/lib/ctf-ir/attributes.c @@ -31,9 +31,10 @@ #include #include #include +#include #include -#include #include +#include #define BT_ATTR_NAME_INDEX 0 #define BT_ATTR_VALUE_INDEX 1 @@ -96,6 +97,13 @@ const char *bt_attributes_get_field_name(struct bt_value *attr_obj, goto end; } + if (index >= bt_value_array_size(attr_obj)) { + BT_LOGW("Invalid parameter: index is out of bounds: " + "index=%" PRIu64 ", count=%" PRId64, + index, bt_value_array_size(attr_obj)); + goto end; + } + attr_field_obj = bt_value_array_get(attr_obj, index); if (!attr_field_obj) { BT_LOGE("Cannot get attributes object's array value's element by index: " @@ -137,6 +145,13 @@ struct bt_value *bt_attributes_get_field_value(struct bt_value *attr_obj, goto end; } + if (index >= bt_value_array_size(attr_obj)) { + BT_LOGW("Invalid parameter: index is out of bounds: " + "index=%" PRIu64 ", count=%" PRId64, + index, bt_value_array_size(attr_obj)); + goto end; + } + attr_field_obj = bt_value_array_get(attr_obj, index); if (!attr_field_obj) { BT_LOGE("Cannot get attributes object's array value's element by index: " @@ -316,7 +331,7 @@ int bt_attributes_freeze(struct bt_value *attr_obj) BT_LOGD("Freezing attributes object: value-addr=%p", attr_obj); count = bt_value_array_size(attr_obj); - assert(count >= 0); + BT_ASSERT(count >= 0); /* * We do not freeze the array value object itself here, since