YaGL: fix eglChooseConfig() for 64-bit hosts
authorIgor Mitsyanko <i.mitsyanko@samsung.com>
Fri, 26 Oct 2012 19:52:14 +0000 (23:52 +0400)
committerEvgeny Voevodin <e.voevodin@samsung.com>
Mon, 26 Nov 2012 09:25:31 +0000 (13:25 +0400)
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 <i.mitsyanko@samsung.com>
hw/yagl_apis/egl/yagl_host_egl_calls.c

index 6d47d23..41dac0a 100644 (file)
@@ -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;