Commit 03b23b9
Fix: set proper size when creating new strings
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.
Signed-off-by: Simon Marchi <[email protected]>
Signed-off-by: Philippe Proulx <[email protected]>
Change-Id: I147cdaaa7cff00ee06ec4c98bd9423a975ddd7701 parent 7e38c84 commit 03b23b9
2 files changed
+2
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
| 187 | + | |
187 | 188 | | |
188 | 189 | | |
189 | 190 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
398 | 398 | | |
399 | 399 | | |
400 | 400 | | |
| 401 | + | |
401 | 402 | | |
402 | 403 | | |
403 | 404 | | |
| |||
0 commit comments