SF patch #1467512, fix double free with triple quoted string in standard build.
This was the result of inconsistent use of PyMem_* and PyObject_* allocators.
By changing to use PyObject_* allocator almost everywhere, this removes
the inconsistency.
diff --git a/Parser/myreadline.c b/Parser/myreadline.c
index a932a87..630997b 100644
--- a/Parser/myreadline.c
+++ b/Parser/myreadline.c
@@ -111,7 +111,7 @@
size_t n;
char *p;
n = 100;
- if ((p = PyMem_MALLOC(n)) == NULL)
+ if ((p = PyObject_MALLOC(n)) == NULL)
return NULL;
fflush(sys_stdout);
#ifndef RISCOS
@@ -130,7 +130,7 @@
case 0: /* Normal case */
break;
case 1: /* Interrupt */
- PyMem_FREE(p);
+ PyObject_FREE(p);
return NULL;
case -1: /* EOF */
case -2: /* Error */
@@ -141,7 +141,7 @@
n = strlen(p);
while (n > 0 && p[n-1] != '\n') {
size_t incr = n+2;
- p = PyMem_REALLOC(p, n + incr);
+ p = PyObject_REALLOC(p, n + incr);
if (p == NULL)
return NULL;
if (incr > INT_MAX) {
@@ -151,14 +151,14 @@
break;
n += strlen(p+n);
}
- return PyMem_REALLOC(p, n+1);
+ return PyObject_REALLOC(p, n+1);
}
/* By initializing this function pointer, systems embedding Python can
override the readline function.
- Note: Python expects in return a buffer allocated with PyMem_Malloc. */
+ Note: Python expects in return a buffer allocated with PyObject_Malloc. */
char *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, char *);