[Forensics-changes] [yara] 129/160: Fix bug while reading from streams in yara-python

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


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

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

commit 4fd401294788203e5d943ec30fac48faa43be54e
Author: Victor M. Alvarez <plusvic at gmail.com>
Date:   Thu May 14 12:12:17 2015 +0200

    Fix bug while reading from streams in yara-python
    
    The reference counter for the bytes object was being decremented before copying the buffer. The buffer was being freed by the garbage collector before memcpy was called.
---
 yara-python/yara-python.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/yara-python/yara-python.c b/yara-python/yara-python.c
index ef94382..b62dbcd 100644
--- a/yara-python/yara-python.c
+++ b/yara-python/yara-python.c
@@ -622,12 +622,15 @@ static size_t flo_read(
 
       int result = PyBytes_AsStringAndSize(bytes, &buffer, &len);
 
-      Py_DECREF(bytes);
-
       if (result == -1 || (size_t) len < size)
+      {
+        Py_DECREF(bytes);
         return i;
+      }
 
       memcpy((char*) ptr + i * size, buffer, size);
+
+      Py_DECREF(bytes);
     }
     else
     {

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