From e28cf83f16529920648db2d993054b35a2d1c9d0 Mon Sep 17 00:00:00 2001 From: Igor Mitsyanko Date: Fri, 26 Oct 2012 23:52:14 +0400 Subject: [PATCH] YaGL: fix eglChooseConfig() for 64-bit hosts The problem is that 'configs' defined as yagl_host_handle *configs = NULL; but code above, when doing sizeof(configs), doesn't want to know a size of host pointer, it wants to know sizeof yagl_host_handle type, which is hardcoded to 4 bytes. This wasn't a problem on 32 bit machines since sizeof(pointer) would return 4 in that case. But in case of 64-bit hosts, it causes memory corruption. Fix is simple, change it to sizeof(*configs) Signed-off-by: Igor Mitsyanko --- hw/yagl_apis/egl/yagl_host_egl_calls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/yagl_apis/egl/yagl_host_egl_calls.c b/hw/yagl_apis/egl/yagl_host_egl_calls.c index 6d47d23..41dac0a 100644 --- a/hw/yagl_apis/egl/yagl_host_egl_calls.c +++ b/hw/yagl_apis/egl/yagl_host_egl_calls.c @@ -683,7 +683,7 @@ bool yagl_host_eglChooseConfig(EGLBoolean* retval, YAGL_LOG_DEBUG("chosen %d configs", num_config); - if (!yagl_mem_prepare(egl_api_ts->ts->mt1, configs_, num_config * sizeof(configs)) || + if (!yagl_mem_prepare(egl_api_ts->ts->mt1, configs_, num_config * sizeof(*configs)) || !yagl_mem_prepare_EGLint(egl_api_ts->ts->mt2, num_config_)) { res = false; goto out; -- 2.7.4