Skip to content

Commit 5662ba1

Browse files
committed
Allow the "match" function to accept pid=0 as an argument.
Because the function was initializing pid as 0, when the user passed pid=0 as an argument it was indistinguishable from not pid being passed at all. Closes VirusTotal/yara#1480
1 parent 1a159c3 commit 5662ba1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

yara-python.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,7 +1499,7 @@ static PyObject* Rules_match(
14991499
char* filepath = NULL;
15001500
Py_buffer data = {0};
15011501

1502-
int pid = 0;
1502+
int pid = -1;
15031503
int timeout = 0;
15041504
int error = ERROR_SUCCESS;
15051505
int fast_mode = 0;
@@ -1535,7 +1535,7 @@ static PyObject* Rules_match(
15351535
&callback_data.which,
15361536
&callback_data.warnings_callback))
15371537
{
1538-
if (filepath == NULL && data.buf == NULL && pid == 0)
1538+
if (filepath == NULL && data.buf == NULL && pid == -1)
15391539
{
15401540
return PyErr_Format(
15411541
PyExc_TypeError,
@@ -1646,7 +1646,7 @@ static PyObject* Rules_match(
16461646

16471647
Py_END_ALLOW_THREADS
16481648
}
1649-
else if (pid != 0)
1649+
else if (pid != -1)
16501650
{
16511651
callback_data.matches = PyList_New(0);
16521652

@@ -1686,7 +1686,7 @@ static PyObject* Rules_match(
16861686
{
16871687
handle_error(error, filepath);
16881688
}
1689-
else if (pid != 0)
1689+
else if (pid != -1)
16901690
{
16911691
handle_error(error, "<proc>");
16921692
}

0 commit comments

Comments
 (0)