[vlc-commits] win32: do not clobber error status when touching thread variables

Rémi Denis-Courmont git at videolan.org
Sun Jul 21 18:47:47 CEST 2013


vlc/vlc-2.1 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Jul 21 19:14:56 2013 +0300| [4f11fe308a61affa6878f0edf7591332173f6b9b] | committer: Rémi Denis-Courmont

win32: do not clobber error status when touching thread variables

(cherry picked from commit 013044c36169a4ef9974423a79432f2092281bf3)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.1.git/?a=commit;h=4f11fe308a61affa6878f0edf7591332173f6b9b
---

 src/win32/thread.c |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/win32/thread.c b/src/win32/thread.c
index 45abc4e..d13ac08 100644
--- a/src/win32/thread.c
+++ b/src/win32/thread.c
@@ -358,12 +358,21 @@ void vlc_threadvar_delete (vlc_threadvar_t *p_tls)
 
 int vlc_threadvar_set (vlc_threadvar_t key, void *value)
 {
-    return TlsSetValue (key->id, value) ? ENOMEM : 0;
+    int saved = GetLastError ();
+    int val = TlsSetValue (key->id, value) ? ENOMEM : 0;
+
+    if (val == 0)
+        SetLastError(saved);
+    return val;
 }
 
 void *vlc_threadvar_get (vlc_threadvar_t key)
 {
-    return TlsGetValue (key->id);
+    int saved = GetLastError ();
+    void *value = TlsGetValue (key->id);
+
+    SetLastError(saved);
+    return value;
 }
 
 /*** Threads ***/



More information about the vlc-commits mailing list