Skip to content

Print all warnings with error_on_warning#157

Merged
plusvic merged 1 commit into
VirusTotal:masterfrom
regeciovad:warnings
Oct 19, 2020
Merged

Print all warnings with error_on_warning#157
plusvic merged 1 commit into
VirusTotal:masterfrom
regeciovad:warnings

Conversation

@regeciovad

Copy link
Copy Markdown
Contributor

Print all warnings in yara.compile, not only one, when the error_on_warning option is set to True.

Comment thread yara-python.c
}
else
{
PyObject* warnings = (PyObject*)user_data;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After this change we don't need to separate functions raise_exception_on_error and raise_exception_on_error_or_warning. The raise_exception_on_error function can raise the exception in case of error and put warnings in the list.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I joined these to functions into a one.

Comment thread yara-python.c
{
PyErr_SetObject(YaraWarningError, warnings);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reference count for the warnings list is not decremented when PyList_Size(warnings) == 0, causing a memory leak. When PyList_Size(warnings) > 0 apparently PyErr_SetObject takes ownership of the list and you don't need decrement the reference count, but I would double check.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I missed that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants