summaryrefslogtreecommitdiff
path: root/PC
diff options
context:
space:
mode:
authorZackery Spytz <zspytz@gmail.com>2018-12-07 05:17:43 -0700
committerSerhiy Storchaka <storchaka@gmail.com>2018-12-07 14:17:43 +0200
commit602d307ac5e8a2da38a193dca3bdfef5994dfe67 (patch)
tree8e876e0142683a7564a391dc6396bc6d33f08639 /PC
parent2db190bb356d00422087e1286637887efb8d97c5 (diff)
downloadcpython-git-602d307ac5e8a2da38a193dca3bdfef5994dfe67.tar.gz
bpo-35436: Add missing PyErr_NoMemory() calls and other minor bug fixes. (GH-11015) (GH-11020)
(cherry picked from commit 4c49da0cb7434c676d70b9ccf38aca82ac0d64a9)
Diffstat (limited to 'PC')
-rw-r--r--PC/getpathp.c12
-rw-r--r--PC/launcher.c3
2 files changed, 13 insertions, 2 deletions
diff --git a/PC/getpathp.c b/PC/getpathp.c
index 4075463f22..1b553d53af 100644
--- a/PC/getpathp.c
+++ b/PC/getpathp.c
@@ -576,6 +576,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 0242f26391..4c620dab7c 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'",