mirror of https://github.com/python/cpython
Issue #16742: My fix on PyOS_StdioReadline() was incomplete, PyMem_FREE() was
not patched
This commit is contained in:
parent
355491dc47
commit
c548660af5
|
@ -140,13 +140,13 @@ PyOS_StdioReadline(FILE *sys_stdin, FILE *sys_stdout, char *prompt)
|
||||||
while (n > 0 && p[n-1] != '\n') {
|
while (n > 0 && p[n-1] != '\n') {
|
||||||
size_t incr = n+2;
|
size_t incr = n+2;
|
||||||
if (incr > INT_MAX) {
|
if (incr > INT_MAX) {
|
||||||
PyMem_FREE(p);
|
PyMem_RawFree(p);
|
||||||
PyErr_SetString(PyExc_OverflowError, "input line too long");
|
PyErr_SetString(PyExc_OverflowError, "input line too long");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
pr = (char *)PyMem_RawRealloc(p, n + incr);
|
pr = (char *)PyMem_RawRealloc(p, n + incr);
|
||||||
if (pr == NULL) {
|
if (pr == NULL) {
|
||||||
PyMem_FREE(p);
|
PyMem_RawFree(p);
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ PyOS_StdioReadline(FILE *sys_stdin, FILE *sys_stdout, char *prompt)
|
||||||
}
|
}
|
||||||
pr = (char *)PyMem_RawRealloc(p, n+1);
|
pr = (char *)PyMem_RawRealloc(p, n+1);
|
||||||
if (pr == NULL) {
|
if (pr == NULL) {
|
||||||
PyMem_FREE(p);
|
PyMem_RawFree(p);
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue