After adding a wrapper to g_array_index that validates that accessed
indices don't go past the end of the arrays, I got this:
(╯°□°)╯︵ ┻━┻ /home/smarchi/src/babeltrace/src/lib/trace-ir/field.c:392: create_string_field(): Assertion `0 < string_field->buf->len` failed.
The problem is that arrays backing string fields are created with:
string->buf = g_array_sized_new(FALSE, FALSE, sizeof(char), 1);
This g_array_sized_new call reserves space for one element, but doesn't
actually make the length of the array one. Add a call to
g_array_set_size to fix that. Fix another occurence of the same bug in
ctf-writer.
Change-Id: I2b90b26c37d70d64bcd825b5b07b204bcbb5baf5
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10904
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
goto end;
}
+ g_array_set_size(string->buf, 1);
g_array_index(string->buf, char, 0) = '\0';
BT_LOGD("Initialized common string field object: addr=%p, ft-addr=%p",
field, type);
goto end;
}
+ g_array_set_size(string_field->buf, 1);
g_array_index(string_field->buf, char, 0) = '\0';
BT_LIB_LOGD("Created string field object: %!+f", string_field);