Patches #925152, #1118602: Avoid reading after the end of the buffer
in pyexpat.GetInputContext. Will backport to 2.4.
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index d359a74..e6c14f8 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -1082,7 +1082,7 @@
= XML_GetInputContext(self->itself, &offset, &size);
if (buffer != NULL)
- result = PyString_FromStringAndSize(buffer + offset, size);
+ result = PyString_FromStringAndSize(buffer + offset, size - offset);
else {
result = Py_None;
Py_INCREF(result);