[Forensics-changes] [yara] 123/415: Fix reference counting bug in	yara-python
    Hilko Bengen 
    bengen at moszumanska.debian.org
       
    Thu Apr  3 05:42:53 UTC 2014
    
    
  
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to branch debian
in repository yara.
commit 9180110141165ad3f41c6abf646c1c8cf4f5a77c
Author: Victor M. Alvarez <plusvic at gmail.com>
Date:   Mon Apr 23 20:29:41 2012 +0000
    Fix reference counting bug in yara-python
---
 yara-python/yara-python.c | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)
diff --git a/yara-python/yara-python.c b/yara-python/yara-python.c
index ae64f0b..1182939 100644
--- a/yara-python/yara-python.c
+++ b/yara-python/yara-python.c
@@ -189,6 +189,8 @@ static PyObject * Match_getattro(PyObject *self, PyObject *name)
 
 static PyObject * Match_richcompare(PyObject *self, PyObject *other, int op)
 {
+    PyObject* result;
+    
     Match *a = (Match *) self;
     Match *b = (Match *) other;
 
@@ -199,16 +201,22 @@ static PyObject * Match_richcompare(PyObject *self, PyObject *other, int op)
         case Py_EQ:
 
             if (PyObject_RichCompareBool(a->rule, b->rule, Py_EQ) && PyObject_RichCompareBool(a->ns, b->ns, Py_EQ))
-                return Py_True;
+                result = Py_True;
             else
-                return Py_False;
+                result = Py_False;
+                
+            Py_INCREF(result);
+            break;
 
         case Py_NE:
 
             if (PyObject_RichCompareBool(a->rule, b->rule, Py_NE) || PyObject_RichCompareBool(a->ns, b->ns, Py_NE))
-                return Py_True;
+                result = Py_True;
             else
-                return Py_False;
+                result = Py_False;
+                
+            Py_INCREF(result);
+            break;
 
         case Py_LT:
         case Py_LE:
@@ -216,13 +224,19 @@ static PyObject * Match_richcompare(PyObject *self, PyObject *other, int op)
         case Py_GE:
 
             if (PyObject_RichCompareBool(a->rule, b->rule, Py_EQ)) 
-                return PyObject_RichCompare(a->ns, b->ns, op);
+                result = PyObject_RichCompare(a->ns, b->ns, op);
             else
-                return PyObject_RichCompare(a->rule, b->rule, op);
+                result = PyObject_RichCompare(a->rule, b->rule, op);
+                
+            break;
         }
     }
-
-    return PyErr_Format(PyExc_TypeError, "'Match' objects must be compared with objects of the same class");
+    else 
+    {
+        result = PyErr_Format(PyExc_TypeError, "'Match' objects must be compared with objects of the same class");
+    }
+    
+    return result;
 
 }
 
-- 
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