FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-149931: Fix memory leaks on failed realloc by aisk · Pull Request #149932 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
6 changes: 4 additions & 2 deletions Modules/_remote_debugging/frames.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@ process_single_stack_chunk(
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);
Expand Down
9 changes: 6 additions & 3 deletions Modules/timemodule.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -820,12 +820,15 @@ time_strftime1(time_char **outbuf, size_t *bufsize,
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) {
Comment thread
aisk marked this conversation as resolved.
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
Expand Down
Loading

Back | FazBrowse Home | New Git URL