Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move return value check right after parser call for fromxml_str() #104

Merged
merged 2 commits into from
Sep 5, 2023

Conversation

kontura
Copy link
Contributor

@kontura kontura commented Aug 22, 2023

For: #103

if (parsed_ret == -1) {
PyErr_SetString(PyCOMPSExc_ParserError, "Fatal parser error");
return NULL;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure that the movement will not create memory leak? There are several object de-alocated after the return.

Copy link
Contributor

Choose a reason for hiding this comment

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

options value could be the first candidate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh right, in case of an error it was causing a memory leak.
I have updated it, please take a look.

It is not sufficient to check the return value after the function output
is used. We need check it sooner to avoid a Segmentation fault.

For: rpm-software-management#103
Remove output checks after the parsing raises and exception.

It also adds one more test with completely invalid xml input.
@jan-kolarik jan-kolarik self-assigned this Sep 1, 2023
@jan-kolarik jan-kolarik merged commit 265c2ad into rpm-software-management:master Sep 5, 2023
4 checks passed
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.

3 participants