Skip to content

Commit 0dd0ed3

Browse files
Dadeos-Menloplusvic
authored andcommitted
Fix issue #242 (#243)
Address incorrect reference counting.
1 parent 836fd9e commit 0dd0ed3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

yara-python.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1884,6 +1884,7 @@ static void StringMatchInstance_dealloc(
18841884

18851885
Py_DECREF(object->offset);
18861886
Py_DECREF(object->matched_data);
1887+
Py_DECREF(object->matched_length);
18871888
Py_DECREF(object->xor_key);
18881889

18891890
PyObject_Del(self);
@@ -1923,7 +1924,10 @@ static PyObject* StringMatchInstance_plaintext(
19231924
StringMatchInstance* instance = (StringMatchInstance*) self;
19241925
uint64_t xor_key = PyLong_AsUnsignedLongLong(instance->xor_key);
19251926
if (xor_key == 0)
1927+
{
1928+
Py_INCREF(instance->matched_data);
19261929
return instance->matched_data;
1930+
}
19271931

19281932
int result = PyBytes_AsStringAndSize(instance->matched_data, &pb, &length);
19291933
if (result == -1)

0 commit comments

Comments
 (0)