[Forensics-changes] [yara] 223/407: Fix incorrect initialization of thread_storage_key in Windows

Hilko Bengen bengen at moszumanska.debian.org
Sat Jul 1 10:28:28 UTC 2017


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag v3.3.0
in repository yara.

commit 141db642fcfeb9d576eba36a1706814effc71256
Author: Victor M. Alvarez <plusvic at gmail.com>
Date:   Fri Nov 21 17:25:02 2014 +0100

    Fix incorrect initialization of thread_storage_key in Windows
---
 libyara/re.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/libyara/re.c b/libyara/re.c
index 2959bf5..2f225d5 100644
--- a/libyara/re.c
+++ b/libyara/re.c
@@ -87,7 +87,7 @@ typedef struct _RE_THREAD_STORAGE
 
 
 #ifdef _WIN32
-DWORD thread_storage_key = INVALID_HANDLE_VALUE;
+DWORD thread_storage_key = 0;
 #else
 pthread_key_t thread_storage_key = 0;
 #endif
@@ -121,12 +121,11 @@ int yr_re_finalize(void)
 {
   #ifdef _WIN32
   TlsFree(thread_storage_key);
-  thread_storage_key = INVALID_HANDLE_VALUE;
   #else
   pthread_key_delete(thread_storage_key);
-  thread_storage_key = 0;
   #endif
 
+  thread_storage_key = 0;
   return ERROR_SUCCESS;
 }
 
@@ -143,17 +142,14 @@ int yr_re_finalize_thread(void)
   RE_FIBER* next_fiber;
   RE_THREAD_STORAGE* storage;
 
-  #ifdef _WIN32
-  if (thread_storage_key != INVALID_HANDLE_VALUE)
-    storage = (RE_THREAD_STORAGE*) TlsGetValue(thread_storage_key);
-  else
-    return ERROR_SUCCESS;
-  #else
   if (thread_storage_key != 0)
+    #ifdef _WIN32
+    storage = (RE_THREAD_STORAGE*) TlsGetValue(thread_storage_key);
+    #else
     storage = (RE_THREAD_STORAGE*) pthread_getspecific(thread_storage_key);
+    #endif
   else
     return ERROR_SUCCESS;
-  #endif
 
   if (storage != NULL)
   {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/forensics/yara.git



More information about the forensics-changes mailing list