From a9633512c38e66ff30b15d0a3037519c298bff7b Mon Sep 17 00:00:00 2001 From: "jinhyung.jo" Date: Thu, 27 Mar 2014 16:21:39 +0900 Subject: [PATCH] VirtGL : Bug fixes prevent memory leaks, release the memory that allocated internally when go out it's scope add a processing when the current_qsurface pointer is NULL fix incorrect error handling that causes a null pointer dereferencing Change-Id: I0ded58fb33ec234d42f3b5f890b77f50ed75a198 Signed-off-by: Jinhyung Jo --- tizen/src/hw/opengl_exec.c | 19 +++++++++++++------ tizen/src/hw/parse_gl_h.c | 1 + 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tizen/src/hw/opengl_exec.c b/tizen/src/hw/opengl_exec.c index 9485593dec..a8f6348c0b 100644 --- a/tizen/src/hw/opengl_exec.c +++ b/tizen/src/hw/opengl_exec.c @@ -1505,6 +1505,9 @@ static char *do_eglShaderPatch(const char *source, int length, int *patched_len) patched = realloc(patched, patched_size + 1); if (!patched) { + if (p) { + free(p); + } return NULL; } } @@ -2055,7 +2058,9 @@ int do_function_call(ProcessState *process, int func_number, process->current_state = glstate; ret.i = glo_surface_makecurrent( - glstate->current_qsurface->surface); + glstate->current_qsurface ? + glstate->current_qsurface->surface + : NULL); /* if (reset_texture) { glo_surface_as_texture( process->current_state->context, @@ -2902,10 +2907,12 @@ int do_function_call(ProcessState *process, int func_number, acc_length += tab_length[i]; } - shadersrc_gles_to_gl(args[1], (const char **)tab_prog, - tab_prog_new, tab_length, tab_length_new); - - if (!tab_prog_new || !tab_length_new) { + if (shadersrc_gles_to_gl(args[1], + (const char **)tab_prog, + tab_prog_new, + tab_length, + tab_length_new) < 0) { + g_free(tab_prog); break; } @@ -2919,7 +2926,7 @@ int do_function_call(ProcessState *process, int func_number, free(tab_prog_new); free(tab_length_new); - free(tab_prog); + g_free(tab_prog); break; } diff --git a/tizen/src/hw/parse_gl_h.c b/tizen/src/hw/parse_gl_h.c index 78fb30b445..3c05912ef1 100644 --- a/tizen/src/hw/parse_gl_h.c +++ b/tizen/src/hw/parse_gl_h.c @@ -851,6 +851,7 @@ int parse(FILE *f, FuncDesc *funcDesc, int funcDescCount, int ignoreEXT) if (ignoreEXT == 1 && isExtByName(fonc)) { free(type); free(fonc); + free(args); continue; } n++; -- 2.34.1