diff options
author | Chia-I Wu <[email protected]> | 2009-09-30 12:28:01 +0800 |
---|---|---|
committer | Brian Paul <[email protected]> | 2009-09-30 08:15:30 -0600 |
commit | e0b2848f4fadc832f68c3c1a059546684935969d (patch) | |
tree | 81b52d301b72a043cbff02f774ae09b51c058ce1 /progs/egl/demo1.c | |
parent | 4b95481e951424e24c9ab817998ae50b54ab9f84 (diff) |
progs/egl: Fix a crash in demo1.
The variable "configs" in main() is used without initialization.
Signed-off-by: Chia-I Wu <[email protected]>
Diffstat (limited to 'progs/egl/demo1.c')
-rw-r--r-- | progs/egl/demo1.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/progs/egl/demo1.c b/progs/egl/demo1.c index 6381ad59e6b..34a516e72fc 100644 --- a/progs/egl/demo1.c +++ b/progs/egl/demo1.c @@ -34,14 +34,9 @@ TestScreens(EGLDisplay dpy) * Print table of all available configurations. */ static void -PrintConfigs(EGLDisplay d) +PrintConfigs(EGLDisplay d, EGLConfig *configs, EGLint numConfigs) { - EGLConfig *configs; - EGLint numConfigs, i; - - eglGetConfigs(d, NULL, 0, &numConfigs); - configs = malloc(sizeof(*configs) *numConfigs); - eglGetConfigs(d, configs, numConfigs, &numConfigs); + EGLint i; printf("Configurations:\n"); printf(" bf lv d st colorbuffer dp st supported \n"); @@ -83,7 +78,6 @@ PrintConfigs(EGLDisplay d) red, green, blue, alpha, depth, stencil, surfString); } - free(configs); } @@ -94,7 +88,8 @@ main(int argc, char *argv[]) int maj, min; EGLContext ctx; EGLSurface pbuffer; - EGLConfig configs[10]; + EGLConfig *configs; + EGLint numConfigs; EGLBoolean b; const EGLint pbufAttribs[] = { EGL_WIDTH, 500, @@ -113,7 +108,11 @@ main(int argc, char *argv[]) printf("EGL version = %d.%d\n", maj, min); printf("EGL_VENDOR = %s\n", eglQueryString(d, EGL_VENDOR)); - PrintConfigs(d); + eglGetConfigs(d, NULL, 0, &numConfigs); + configs = malloc(sizeof(*configs) *numConfigs); + eglGetConfigs(d, configs, numConfigs, &numConfigs); + + PrintConfigs(d, configs, numConfigs); ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL); if (ctx == EGL_NO_CONTEXT) { @@ -127,6 +126,8 @@ main(int argc, char *argv[]) return 0; } + free(configs); + b = eglMakeCurrent(d, pbuffer, pbuffer, ctx); if (!b) { printf("make current failed\n"); |