1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-30 22:43:12 +03:00

Always check dtv before freeing dtv[-1]

This commit is contained in:
H.J. Lu
2012-09-05 12:24:37 -07:00
parent f5fce0629a
commit 0948c3af9d
3 changed files with 9 additions and 2 deletions

View File

@ -1,3 +1,10 @@
2012-09-06 H.J. Lu <hongjiu.lu@intel.com>
[BZ #14545]
* csu/libc-tls.c (_dl_initial_dtv): New variable.
* elf/dl-tls.c (_dl_deallocate_tls): Always check dtv before
freeing dtv[-1].
2012-09-06 H.J. Lu <hongjiu.lu@intel.com> 2012-09-06 H.J. Lu <hongjiu.lu@intel.com>
[BZ #14544] [BZ #14544]

View File

@ -65,6 +65,8 @@ size_t _dl_tls_static_size = 2048;
size_t _dl_tls_static_used; size_t _dl_tls_static_used;
/* Alignment requirement of the static TLS block. */ /* Alignment requirement of the static TLS block. */
size_t _dl_tls_static_align; size_t _dl_tls_static_align;
/* Initial dtv of the main thread, not allocated with normal malloc. */
void *_dl_initial_dtv = &static_dtv[1];
/* Generation counter for the dtv. */ /* Generation counter for the dtv. */
size_t _dl_tls_generation; size_t _dl_tls_generation;

View File

@ -477,9 +477,7 @@ _dl_deallocate_tls (void *tcb, bool dealloc_tcb)
free (dtv[1 + cnt].pointer.val); free (dtv[1 + cnt].pointer.val);
/* The array starts with dtv[-1]. */ /* The array starts with dtv[-1]. */
#ifdef SHARED
if (dtv != GL(dl_initial_dtv)) if (dtv != GL(dl_initial_dtv))
#endif
free (dtv - 1); free (dtv - 1);
if (dealloc_tcb) if (dealloc_tcb)