From a54f72f0613210c9dfbcc1068749c8110ab7378d Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 14 Sep 2017 12:13:33 -0400 Subject: [PATCH] Fix: ensure sequence length field value is set and freeze it MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- lib/ctf-ir/fields.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/ctf-ir/fields.c b/lib/ctf-ir/fields.c index 05be90fe..65f31b38 100644 --- a/lib/ctf-ir/fields.c +++ b/lib/ctf-ir/fields.c @@ -483,6 +483,15 @@ int bt_ctf_field_sequence_set_length(struct bt_ctf_field *field, goto end; } + if (!bt_ctf_field_value_is_set(length_field)) { + BT_LOGW("Invalid parameter: length field's value is not set: " + "field-addr=%p, length-field-addr=%p, " + "length-field-ft-addr=%p", field, length_field, + length_field->type); + ret = -1; + goto end; + } + length = container_of(length_field, struct bt_ctf_field_integer, parent); sequence_length = length->payload.unsignd; @@ -504,6 +513,7 @@ int bt_ctf_field_sequence_set_length(struct bt_ctf_field *field, g_ptr_array_set_size(sequence->elements, (size_t) sequence_length); bt_get(length_field); sequence->length = length_field; + bt_ctf_field_freeze(length_field); end: return ret; } -- 2.34.1