diff options
author | Larry Hastings <larry@hastings.org> | 2015-02-26 05:58:48 -0800 |
---|---|---|
committer | Larry Hastings <larry@hastings.org> | 2015-02-26 05:58:48 -0800 |
commit | 8c3ec536e924002dc3afe4ff92e32fe9ed82ebab (patch) | |
tree | f141eec287584ba9d58d32461e1a7d92b5466e91 /Python | |
parent | e287746401398ee81c8e8a1513a5fe828eb32559 (diff) | |
parent | 7b2c3c6840052ea6f8b41253faf38b9e24f9a453 (diff) | |
download | cpython-git-8c3ec536e924002dc3afe4ff92e32fe9ed82ebab.tar.gz |
Merge 3.4.3 release engineering changes back into 3.4.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/frozenmain.c | 15 | ||||
-rw-r--r-- | Python/peephole.c | 4 |
2 files changed, 11 insertions, 8 deletions
diff --git a/Python/frozenmain.c b/Python/frozenmain.c index 55d05fc26f..b05c94a7e1 100644 --- a/Python/frozenmain.c +++ b/Python/frozenmain.c @@ -24,11 +24,13 @@ Py_FrozenMain(int argc, char **argv) /* We need a second copies, as Python might modify the first one. */ wchar_t **argv_copy2 = NULL; - argv_copy = PyMem_RawMalloc(sizeof(wchar_t*) * argc); - argv_copy2 = PyMem_RawMalloc(sizeof(wchar_t*) * argc); - if (!argv_copy || !argv_copy2) { - fprintf(stderr, "out of memory\n"); - goto error; + if (argc > 0) { + argv_copy = PyMem_RawMalloc(sizeof(wchar_t*) * argc); + argv_copy2 = PyMem_RawMalloc(sizeof(wchar_t*) * argc); + if (!argv_copy || !argv_copy2) { + fprintf(stderr, "out of memory\n"); + goto error; + } } Py_FrozenFlag = 1; /* Suppress errors from getpath.c */ @@ -68,7 +70,8 @@ Py_FrozenMain(int argc, char **argv) #ifdef MS_WINDOWS PyInitFrozenExtensions(); #endif /* MS_WINDOWS */ - Py_SetProgramName(argv_copy[0]); + if (argc >= 1) + Py_SetProgramName(argv_copy[0]); Py_Initialize(); #ifdef MS_WINDOWS PyWinFreeze_ExeInit(); diff --git a/Python/peephole.c b/Python/peephole.c index 4185462b34..c56c8fcc23 100644 --- a/Python/peephole.c +++ b/Python/peephole.c @@ -290,7 +290,7 @@ fold_unaryops_on_constants(unsigned char *codestr, PyObject *consts, PyObject *v static unsigned int * markblocks(unsigned char *code, Py_ssize_t len) { - unsigned int *blocks = (unsigned int *)PyMem_Malloc(len*sizeof(int)); + unsigned int *blocks = PyMem_New(unsigned int, len); int i,j, opcode, blockcnt = 0; if (blocks == NULL) { @@ -398,7 +398,7 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names, goto exitUnchanged; /* Mapping to new jump targets after NOPs are removed */ - addrmap = (int *)PyMem_Malloc(codelen * sizeof(int)); + addrmap = PyMem_New(int, codelen); if (addrmap == NULL) { PyErr_NoMemory(); goto exitError; |