diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2021-03-13 16:43:15 +0100 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2021-03-13 16:43:15 +0100 |
| commit | 3dda84e58b148f92b2bb4d94caacc84011fa3919 (patch) | |
| tree | 7d370254ff4d0cb764c08dc48a2c59f1b3262229 /src | |
| parent | 0823bfaed2977a38aa4cfc582d09a071a7a21b67 (diff) | |
| download | box64-3dda84e58b148f92b2bb4d94caacc84011fa3919.tar.gz box64-3dda84e58b148f92b2bb4d94caacc84011fa3919.zip | |
Fixed a few minor leaks
Diffstat (limited to 'src')
| -rwxr-xr-x | src/libtools/signals.c | 2 | ||||
| -rwxr-xr-x | src/libtools/threads.c | 22 |
2 files changed, 19 insertions, 5 deletions
diff --git a/src/libtools/signals.c b/src/libtools/signals.c index 483013f1..4ceac2d7 100755 --- a/src/libtools/signals.c +++ b/src/libtools/signals.c @@ -1133,7 +1133,7 @@ void init_signal_helper(box64context_t* context) for(int i=0; i<MAX_SIGNAL; ++i) { context->signals[i] = 1; // SIG_DFL } - struct sigaction action; + struct sigaction action = {0}; action.sa_flags = SA_SIGINFO | SA_RESTART | SA_NODEFER; action.sa_sigaction = my_box86signalhandler; sigaction(SIGSEGV, &action, NULL); diff --git a/src/libtools/threads.c b/src/libtools/threads.c index b3e208fd..3e1a8eaa 100755 --- a/src/libtools/threads.c +++ b/src/libtools/threads.c @@ -152,8 +152,10 @@ typedef struct emuthread_s { static void emuthread_destroy(void* p) { emuthread_t *et = (emuthread_t*)p; - FreeX64Emu(&et->emu); - free(et); + if(et) { + FreeX64Emu(&et->emu); + free(et); + } } static pthread_key_t thread_key; @@ -732,8 +734,10 @@ EXPORT int my_pthread_mutex_unlock(pthread_mutex_t *m) static void emujmpbuf_destroy(void* p) { emu_jmpbuf_t *ej = (emu_jmpbuf_t*)p; - free(ej->jmpbuf); - free(ej); + if(ej) { + free(ej->jmpbuf); + free(ej); + } } static pthread_key_t jmpbuf_key; @@ -778,4 +782,14 @@ void fini_pthread_helper(box64context_t* context) ); kh_destroy(mutex, unaligned_mutex); #endif + emu_jmpbuf_t *ejb = (emu_jmpbuf_t*)pthread_getspecific(jmpbuf_key); + if(ejb) { + emujmpbuf_destroy(ejb); + pthread_setspecific(jmpbuf_key, NULL); + } + emuthread_t *et = (emuthread_t*)pthread_getspecific(thread_key); + if(et) { + emuthread_destroy(et); + pthread_setspecific(thread_key, NULL); + } } |