summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTAGAMI Yukihiro <tagami.yukihiro@gmail.com>2021-10-02 09:57:13 (GMT)
committerGitHub <noreply@github.com>2021-10-02 09:57:13 (GMT)
commit0742abdc48886b74ed3b66985a54bb1c32802670 (patch)
tree8fc3d4429595c75b74de5d5dbaa1b0a1787e1864
parent417faa69bd48dfc22e4eff9bb2c610f53d59d02f (diff)
downloadcpython-0742abdc48886b74ed3b66985a54bb1c32802670.zip
cpython-0742abdc48886b74ed3b66985a54bb1c32802670.tar.gz
cpython-0742abdc48886b74ed3b66985a54bb1c32802670.tar.bz2
bpo-45329: Fix freed memory access in pyexpat.c (GH-28649)
-rw-r--r--Misc/NEWS.d/next/Library/2021-10-01-13-09-53.bpo-45329.9iMYaO.rst2
-rw-r--r--Modules/pyexpat.c2
2 files changed, 3 insertions, 1 deletions
diff --git a/Misc/NEWS.d/next/Library/2021-10-01-13-09-53.bpo-45329.9iMYaO.rst b/Misc/NEWS.d/next/Library/2021-10-01-13-09-53.bpo-45329.9iMYaO.rst
new file mode 100644
index 0000000..b4bedbc
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2021-10-01-13-09-53.bpo-45329.9iMYaO.rst
@@ -0,0 +1,2 @@
+Fix freed memory access in :class:`pyexpat.xmlparser` when building it with an
+installed expat library <= 2.2.0.
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index ec68463..b3d9bdd 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -1204,10 +1204,10 @@ static void
xmlparse_dealloc(xmlparseobject *self)
{
PyObject_GC_UnTrack(self);
+ (void)xmlparse_clear(self);
if (self->itself != NULL)
XML_ParserFree(self->itself);
self->itself = NULL;
- (void)xmlparse_clear(self);
if (self->handlers != NULL) {
PyMem_Free(self->handlers);