summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gmail.com>2020-03-09 16:16:17 +0000
committerEmmanuele Bassi <ebassi@gmail.com>2020-03-09 16:16:17 +0000
commitd205b8b73dc772f9da76a879107a9164de24618b (patch)
tree6cf6c17155b273acbad87f5cff3791c2d53c3606
parent95342464a8912861f43f9aa3addf4f48a0518d8c (diff)
parent0f5f3179c0b59b7c03339d39a0661f07aab37e6e (diff)
downloadcogl-d205b8b73dc772f9da76a879107a9164de24618b.tar.gz
Merge branch 'wip/smcv/test-premult-use-after-free-1.22' into 'cogl-1.22'
[1.22] test-premult: Don't free texture data until CoglBitmap is freed See merge request GNOME/cogl!12
-rw-r--r--tests/conform/test-conform-main.c2
-rw-r--r--tests/conform/test-premult.c6
2 files changed, 6 insertions, 2 deletions
diff --git a/tests/conform/test-conform-main.c b/tests/conform/test-conform-main.c
index 9b6573d9..ee668999 100644
--- a/tests/conform/test-conform-main.c
+++ b/tests/conform/test-conform-main.c
@@ -55,7 +55,7 @@ main (int argc, char **argv)
ADD_TEST (test_pipeline_user_matrix, 0, 0);
ADD_TEST (test_blend_strings, 0, 0);
ADD_TEST (test_blend, 0, 0);
- ADD_TEST (test_premult, 0, TEST_KNOWN_FAILURE);
+ ADD_TEST (test_premult, 0, 0);
UNPORTED_TEST (test_readpixels);
#ifdef COGL_HAS_COGL_PATH_SUPPORT
ADD_TEST (test_path, 0, 0);
diff --git a/tests/conform/test-premult.c b/tests/conform/test-premult.c
index fa60bdf1..9ac7b680 100644
--- a/tests/conform/test-premult.c
+++ b/tests/conform/test-premult.c
@@ -49,6 +49,7 @@ make_texture (uint32_t color,
CoglPixelFormat src_format,
MakeTextureFlags flags)
{
+ static CoglUserDataKey bitmap_free_key;
CoglTexture2D *tex_2d;
guchar *tex_data = gen_tex_data (color);
CoglBitmap *bmp = cogl_bitmap_new_for_data (test_ctx,
@@ -57,6 +58,10 @@ make_texture (uint32_t color,
src_format,
QUAD_WIDTH * 4,
tex_data);
+ cogl_object_set_user_data (COGL_OBJECT (bmp),
+ &bitmap_free_key,
+ tex_data,
+ g_free);
tex_2d = cogl_texture_2d_new_from_bitmap (bmp);
@@ -66,7 +71,6 @@ make_texture (uint32_t color,
cogl_texture_set_premultiplied (tex_2d, FALSE);
cogl_object_unref (bmp);
- g_free (tex_data);
return tex_2d;
}