diff options
Diffstat (limited to 'PC')
-rw-r--r-- | PC/getpathp.c | 12 | ||||
-rw-r--r-- | PC/launcher.c | 3 |
2 files changed, 13 insertions, 2 deletions
diff --git a/PC/getpathp.c b/PC/getpathp.c index 452501a..76d3a08 100644 --- a/PC/getpathp.c +++ b/PC/getpathp.c @@ -575,6 +575,9 @@ read_pth_file(_PyPathConfig *config, wchar_t *prefix, const wchar_t *path) size_t prefixlen = wcslen(prefix); wchar_t *buf = (wchar_t*)PyMem_RawMalloc(bufsiz * sizeof(wchar_t)); + if (buf == NULL) { + goto error; + } buf[0] = '\0'; while (!feof(sp_file)) { @@ -603,17 +606,22 @@ read_pth_file(_PyPathConfig *config, wchar_t *prefix, const wchar_t *path) DWORD wn = MultiByteToWideChar(CP_UTF8, 0, line, -1, NULL, 0); wchar_t *wline = (wchar_t*)PyMem_RawMalloc((wn + 1) * sizeof(wchar_t)); + if (wline == NULL) { + goto error; + } wn = MultiByteToWideChar(CP_UTF8, 0, line, -1, wline, wn + 1); wline[wn] = '\0'; size_t usedsiz = wcslen(buf); while (usedsiz + wn + prefixlen + 4 > bufsiz) { bufsiz += MAXPATHLEN; - buf = (wchar_t*)PyMem_RawRealloc(buf, (bufsiz + 1) * sizeof(wchar_t)); - if (!buf) { + wchar_t *tmp = (wchar_t*)PyMem_RawRealloc(buf, (bufsiz + 1) * + sizeof(wchar_t)); + if (tmp == NULL) { PyMem_RawFree(wline); goto error; } + buf = tmp; } if (usedsiz) { diff --git a/PC/launcher.c b/PC/launcher.c index 0242f26..4c620da 100644 --- a/PC/launcher.c +++ b/PC/launcher.c @@ -1763,6 +1763,9 @@ process(int argc, wchar_t ** argv) } cch += (DWORD)wcslen(PYTHON_EXECUTABLE) + 1 + 1; /* include sep and null */ executable = (wchar_t *)malloc(cch * sizeof(wchar_t)); + if (executable == NULL) { + error(RC_NO_MEMORY, L"A memory allocation failed"); + } cch_actual = MultiByteToWideChar(CP_UTF8, 0, start, len, executable, cch); if (!cch_actual) { error(RC_BAD_VENV_CFG, L"Cannot decode home path in '%ls'", |