[Forensics-changes] [yara] 59/368: Allow multiple calls to yr_initialize/yr_finalize

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


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

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

commit 39066f32d6ed86292861cee2a6dac1487deb0626
Author: Victor Manuel Alvarez <vmalvarez at virustotal.com>
Date:   Tue Sep 22 10:13:02 2015 +0200

    Allow multiple calls to yr_initialize/yr_finalize
---
 libyara/libyara.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/libyara/libyara.c b/libyara/libyara.c
index 6d20ad0..96c2897 100644
--- a/libyara/libyara.c
+++ b/libyara/libyara.c
@@ -38,6 +38,7 @@ pthread_key_t tidx_key;
 pthread_key_t recovery_state_key;
 #endif
 
+static int init_count = 0;
 
 char lowercase[256];
 char altercase[256];
@@ -53,6 +54,11 @@ YR_API int yr_initialize(void)
 {
   int i;
 
+  init_count++;
+
+  if (init_count > 1)
+    return ERROR_SUCCESS;
+
   for (i = 0; i < 256; i++)
   {
     if (i >= 'a' && i <= 'z')
@@ -106,6 +112,9 @@ YR_API int yr_finalize(void)
 {
   yr_re_finalize_thread();
 
+  if (--init_count > 0)
+    return ERROR_SUCCESS;
+
   #ifdef _WIN32
   TlsFree(tidx_key);
   TlsFree(recovery_state_key);

-- 
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