X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=ltt%2Flttvtraceread_loader.c;h=6b519be5c2e24bf9ae8664d7e947329bbe97ac13;hb=f87369bbd73c812a940a0b3905f9bec9811355d2;hp=e2f0da9b4e59d8b2bed1264a3ac923b8b413bfad;hpb=b86b39e95fed6940c70d4baf400f21e564be971a;p=lttv.git diff --git a/ltt/lttvtraceread_loader.c b/ltt/lttvtraceread_loader.c index e2f0da9b..6b519be5 100644 --- a/ltt/lttvtraceread_loader.c +++ b/ltt/lttvtraceread_loader.c @@ -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;