Skip to content

bpo-31455: fix reference leak#6318

Merged
serhiy-storchaka merged 4 commits intopython:2.7from
scoder:bpo_31455_27
Mar 31, 2018
Merged

bpo-31455: fix reference leak#6318
serhiy-storchaka merged 4 commits intopython:2.7from
scoder:bpo_31455_27

Conversation

@scoder
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

4 participants