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

bpo-31455: fix reference leak #6318

Merged
merged 4 commits into from Mar 31, 2018
Merged

Conversation

scoder
Copy link
Contributor

@scoder scoder commented Mar 31, 2018

Fixes a reference leak to 'self' in the previous implementation.

https://bugs.python.org/issue31455

…executing user code) with a live exception set.

Backport to Py2.7
…rror handling fixes.

This change generally splits the xmlparser creation code into an unsafe part with "rollback" error handling and a safe "object initialisation done" part with normal decref cleanup.
@scoder
Copy link
Contributor Author

scoder commented Mar 31, 2018

The travis build failure seems unrelated. The relevant tests had already passed by then.

ALLOC(sizeof(XMLParserObject), "create expatparser");

/* Init to NULL to keep the error handling below manageable. */
self->target =
Copy link
Member

Choose a reason for hiding this comment

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

This is not needed. PyObject_New() clears the memory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought so, too, until the test started crashing due to uninitalised struct fields.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, seems I remember this wrong.

ALLOC(sizeof(XMLParserObject), "create expatparser");

/* Init to NULL to keep the error handling below manageable. */
self->target =
Copy link
Member

Choose a reason for hiding this comment

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

Oh, seems I remember this wrong.

@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Mar 31, 2018

Seems the test is failed for unrelated cause.

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.

None yet

4 participants