]> git.ipfire.org Git - thirdparty/libvirt.git/commit
win32: Properly handle TlsGetValue returning NULL
authorMatthias Bolte <matthias.bolte@googlemail.com>
Sat, 21 Apr 2012 17:03:08 +0000 (19:03 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Sat, 21 Apr 2012 17:03:08 +0000 (19:03 +0200)
commite0aba54bd1935ab7f33969359651e615e363c14c
tree07f5f3e9767e27e988ab1eeec3c9046dab48db53
parentb126715a48cd0cbe32ec6468c267cd8cf2961c55
win32: Properly handle TlsGetValue returning NULL

virThreadSelf tries to access the virThreadPtr stored in TLS for the
current thread via TlsGetValue. When virThreadSelf is called on a thread
that was not created via virThreadCreate (e.g. the main thread) then
TlsGetValue returns NULL as TlsAlloc initializes TLS slots to NULL.

virThreadSelf can be called on the main thread via this call chain from
virsh

vshDeinit
virEventAddTimeout
virEventPollAddTimeout
virEventPollInterruptLocked
virThreadIsSelf

triggering a segfault as virThreadSelf unconditionally dereferences the
return value of TlsGetValue.

Fix this by making virThreadSelf check the TLS slot value for NULL and
setting the given virThreadPtr accordingly.

Reported by Marcel Müller.
src/util/threads-win32.c