Changed freeHandle() to test for empty before calling free
authorWilliam Bourque <william.bourque@polymtl.ca>
Mon, 19 Apr 2010 22:33:46 +0000 (18:33 -0400)
committerWilliam Bourque <william.bourque@polymtl.ca>
Mon, 19 Apr 2010 22:33:46 +0000 (18:33 -0400)
ltt/lttvtraceread_loader.c

index e2f0da9b4e59d8b2bed1264a3ac923b8b413bfad..6b519be5c2e24bf9ae8664d7e947329bbe97ac13 100644 (file)
@@ -138,17 +138,27 @@ JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_factory_JniTraceVer
 }
 
 void freeAllHandle() {
-        free(version_table);
-        free(version_functions_table);
+        if ( version_table != NULL ) {
+                free(version_table);
+                version_table = NULL;
+        }
+        
+        if ( version_functions_table != NULL ) {
+                free(version_functions_table);
+                version_functions_table = NULL;
+        }
 }
 
 void freeHandle(int handle_id) {
-        if (version_table[handle_id].static_handle != NULL) {
-                /* Memory will be freed by dlclose as well */
-                dlclose(version_table[handle_id].static_handle);
-                version_table[handle_id].static_handle = NULL;
-                free(version_table[handle_id].libname);
-                version_table[handle_id].libname = NULL;
+        
+        if ( handle_id >= nb_id ) {
+                if (version_table[handle_id].static_handle != NULL) {
+                        /* Memory will be freed by dlclose as well */
+                        dlclose(version_table[handle_id].static_handle);
+                        version_table[handle_id].static_handle = NULL;
+                        free(version_table[handle_id].libname);
+                        version_table[handle_id].libname = NULL;
+                }
         }
         
         int isEmpty = 1;
This page took 0.025261 seconds and 4 git commands to generate.