return -1;
}
- this_chunk = PyMem_RawRealloc(this_chunk, actual_size);
- if (!this_chunk) {
+ char *tmp = PyMem_RawRealloc(this_chunk, actual_size);
+ if (!tmp) {
+ PyMem_RawFree(this_chunk);
PyErr_NoMemory();
set_exception_cause(unwinder, PyExc_MemoryError, "Failed to reallocate stack chunk buffer");
return -1;
}
+ this_chunk = tmp;
if (_Py_RemoteDebug_PagedReadRemoteMemory(&unwinder->handle, chunk_addr, actual_size, this_chunk) < 0) {
PyMem_RawFree(this_chunk);
PyErr_NoMemory();
return NULL;
}
- *outbuf = (time_char *)PyMem_Realloc(*outbuf,
- *bufsize*sizeof(time_char));
- if (*outbuf == NULL) {
+ time_char *tmp = (time_char *)PyMem_Realloc(*outbuf,
+ *bufsize*sizeof(time_char));
+ if (tmp == NULL) {
+ PyMem_Free(*outbuf);
+ *outbuf = NULL;
PyErr_NoMemory();
return NULL;
}
+ *outbuf = tmp;
#if defined _MSC_VER && _MSC_VER >= 1400 && defined(__STDC_SECURE_LIB__)
errno = 0;
#endif