https://github.com/python/cpython/commit/d12b08b1b6a3635c5f518d0a9568449d41dace2e
commit: d12b08b1b6a3635c5f518d0a9568449d41dace2e
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: sobolevn <[email protected]>
date: 2026-11-14T06:10:00Z
summary:

[3.14] gh-101703: Use `PyOS_snprintf` in `_freeze_module` (GH-161871) (#161981)

gh-101703: Use `PyOS_snprintf` in `_freeze_module` (GH-161871)
(cherry picked from commit 713c16ec40960b800a473b5be5483c7b007bea24)

Co-authored-by: sobolevn <[email protected]>

files:
M Programs/_freeze_module.c

diff --git a/Programs/_freeze_module.c b/Programs/_freeze_module.c
index 06d1ee016dc2a80..721cc30672a6639 100644
--- a/Programs/_freeze_module.c
+++ b/Programs/_freeze_module.c
@@ -109,11 +109,12 @@ read_text(const char *inpath)
 static PyObject *
 compile_and_marshal(const char *name, const char *text)
 {
-    char *filename = (char *) malloc(strlen(name) + 10);
+    int text_size = strlen(name) + 10;
+    char *filename = (char *) malloc(text_size);
     if (filename == NULL) {
         return PyErr_NoMemory();
     }
-    sprintf(filename, "<frozen %s>", name);
+    PyOS_snprintf(filename, text_size, "<frozen %s>", name);
     PyObject *code = Py_CompileStringExFlags(text, filename,
                                              Py_file_input, NULL, 0);
     free(filename);

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to