diff options
author | shadchin <[email protected]> | 2024-10-27 10:52:33 +0300 |
---|---|---|
committer | shadchin <[email protected]> | 2024-10-27 11:03:47 +0300 |
commit | 1529383373617c6d14ad4972afdc46a5eb35f954 (patch) | |
tree | 229b7647fafadd4ee4b93d20e606c534ad697365 /contrib/tools/python3/Programs | |
parent | 41d598c624442bf6918407466dac3316b8277347 (diff) |
Update Python 3 to 3.12.7
commit_hash:052a122399d67f1ea5dfbc5f6457e3e06200becf
Diffstat (limited to 'contrib/tools/python3/Programs')
-rw-r--r-- | contrib/tools/python3/Programs/_freeze_module.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/contrib/tools/python3/Programs/_freeze_module.c b/contrib/tools/python3/Programs/_freeze_module.c index e55f1d56745..c669d96c173 100644 --- a/contrib/tools/python3/Programs/_freeze_module.c +++ b/contrib/tools/python3/Programs/_freeze_module.c @@ -123,6 +123,9 @@ static PyObject * compile_and_marshal(const char *name, const char *text) { char *filename = (char *) malloc(strlen(name) + 10); + if (filename == NULL) { + return PyErr_NoMemory(); + } sprintf(filename, "<frozen %s>", name); PyObject *code = Py_CompileStringExFlags(text, filename, Py_file_input, NULL, 0); @@ -146,6 +149,9 @@ get_varname(const char *name, const char *prefix) { size_t n = strlen(prefix); char *varname = (char *) malloc(strlen(name) + n + 1); + if (varname == NULL) { + return NULL; + } (void)strcpy(varname, prefix); for (size_t i = 0; name[i] != '\0'; i++) { if (name[i] == '.') { @@ -191,6 +197,11 @@ write_frozen(const char *outpath, const char *inpath, const char *name, fprintf(outfile, "%s\n", header); char *arrayname = get_varname(name, "_Py_M__"); + if (arrayname == NULL) { + fprintf(stderr, "memory error: could not allocate varname\n"); + fclose(outfile); + return -1; + } write_code(outfile, marshalled, arrayname); free(arrayname); |