VirtGL : Bug fixes 21/18621/1
authorjinhyung.jo <jinhyung.jo@samsung.com>
Thu, 27 Mar 2014 07:21:39 +0000 (16:21 +0900)
committerjinhyung.jo <jinhyung.jo@samsung.com>
Thu, 27 Mar 2014 07:21:39 +0000 (16:21 +0900)
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 <jinhyung.jo@samsung.com>
tizen/src/hw/opengl_exec.c
tizen/src/hw/parse_gl_h.c

index 9485593..a8f6348 100644 (file)
@@ -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;
         }
index 78fb30b..3c05912 100644 (file)
@@ -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++;