https://github.com/python/cpython/commit/713c16ec40960b800a473b5be5483c7b007bea24
commit: 713c16ec40960b800a473b5be5483c7b007bea24
branch: main
author: sobolevn <[email protected]>
committer: sobolevn <[email protected]>
date: 2026-11-14T08:36:06+03:00
summary:
gh-101703: Use `PyOS_snprintf` in `_freeze_module` (#161871)
files:
M Programs/_freeze_module.c
diff --git a/Programs/_freeze_module.c b/Programs/_freeze_module.c
index 27a60171f3eca86..ae134f6caef1d59 100644
--- a/Programs/_freeze_module.c
+++ b/Programs/_freeze_module.c
@@ -122,11 +122,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]