1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
From: Philip Chimento <philip.chimento@gmail.com>
Date: Sun, 28 Sep 2025 21:01:19 -0700
Subject: Fix memory errors in
gi_marshalling_tests_length_array_utf8_full_inout
The int* length can't be cast to size_t*, because there may be junk in the
extra bits. We have to cast int to size_t, then pass a size_t*, then cast
size_t back to int.
We also have to free the in-array if we replace it with a new out-array.
Origin: upstream, commit:https://gitlab.gnome.org/GNOME/gobject-introspection-tests/-/merge_requests/27/diffs?commit_id=4b26d464a16c262b7c4a87821df3caedf9058a0e
---
.../gimarshallingtests.c | 27 ++++++++++++++--------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/subprojects/gobject-introspection-tests/gimarshallingtests.c b/subprojects/gobject-introspection-tests/gimarshallingtests.c
index 55922cf..4e6baf1 100644
--- a/subprojects/gobject-introspection-tests/gimarshallingtests.c
+++ b/subprojects/gobject-introspection-tests/gimarshallingtests.c
@@ -2841,19 +2841,26 @@ void
gi_marshalling_tests_length_array_utf8_optional_inout (int *inout_length, char **array_inout[])
{
if (*inout_length > 0)
- gi_marshalling_tests_length_array_utf8_full_inout (array_inout, (size_t *) inout_length);
- else {
- gchar **array_out = g_new0 (gchar *, 2);
+ {
+ size_t size = *inout_length;
+ gi_marshalling_tests_length_array_utf8_full_inout (array_inout, &size);
+ *inout_length = size;
+ }
+ else
+ {
+ g_free (*array_inout);
+
+ gchar **array_out = g_new0 (gchar *, 2);
- g_assert_nonnull (inout_length);
- g_assert_nonnull (array_inout);
+ g_assert_nonnull (inout_length);
+ g_assert_nonnull (array_inout);
- array_out[0] = g_strdup ("a");
- array_out[1] = g_strdup ("b");
+ array_out[0] = g_strdup ("a");
+ array_out[1] = g_strdup ("b");
- *array_inout = array_out;
- *inout_length = 2;
- }
+ *array_inout = array_out;
+ *inout_length = 2;
+ }
}
/**
|