diff --git a/lib/bcheck.c b/lib/bcheck.c index ab8f4675..fe1e82ec 100644 --- a/lib/bcheck.c +++ b/lib/bcheck.c @@ -522,17 +522,6 @@ void __attribute__((destructor)) __bound_exit(void) } #endif -#if TREE_REUSE - while (tree_free_list) { - Tree *next = tree_free_list->left; -#if MALLOC_REDIR - free_redir (tree_free_list); -#else - free (tree_free_list); -#endif - tree_free_list = next; - } -#endif for (i = 0; i < FREE_REUSE_SIZE; i++) { if (free_reuse_list[i]) { tree = splay_delete ((size_t) free_reuse_list[i], tree); @@ -551,6 +540,17 @@ void __attribute__((destructor)) __bound_exit(void) } tree = splay_delete (tree->start, tree); } +#if TREE_REUSE + while (tree_free_list) { + Tree *next = tree_free_list->left; +#if MALLOC_REDIR + free_redir (tree_free_list); +#else + free (tree_free_list); +#endif + tree_free_list = next; + } +#endif EXIT_SEM (); inited = 0; #ifdef BOUND_STATISTIC diff --git a/tccrun.c b/tccrun.c index cca6a251..46abbaeb 100644 --- a/tccrun.c +++ b/tccrun.c @@ -254,14 +254,14 @@ static int tcc_relocate_ex(TCCState *s1, void *ptr, addr_t ptr_diff) length = s->data_offset; ptr = (void*)s->sh_addr; if (s->sh_flags & SHF_EXECINSTR) - ptr = (char*)ptr - ptr_diff; + ptr = (char*)((addr_t)ptr - ptr_diff); if (NULL == s->data || s->sh_type == SHT_NOBITS) memset(ptr, 0, length); else memcpy(ptr, s->data, length); /* mark executable sections as executable in memory */ if (s->sh_flags & SHF_EXECINSTR) - set_pages_executable(s1, (char*)ptr + ptr_diff, length); + set_pages_executable(s1, (char*)((addr_t)ptr + ptr_diff), length); } #ifdef _WIN64