Skip to content

Commit d12b08b

Browse files
[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 713c16e) Co-authored-by: sobolevn <mail@sobolevn.me>
1 parent 9629dfe commit d12b08b

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎Programs/_freeze_module.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,12 @@ read_text(const char *inpath)
109109
static PyObject *
110110
compile_and_marshal(const char *name, const char *text)
111111
{
112-
char *filename = (char *) malloc(strlen(name) + 10);
112+
int text_size = strlen(name) + 10;
113+
char *filename = (char *) malloc(text_size);
113114
if (filename == NULL) {
114115
return PyErr_NoMemory();
115116
}
116-
sprintf(filename, "<frozen %s>", name);
117+
PyOS_snprintf(filename, text_size, "<frozen %s>", name);
117118
PyObject *code = Py_CompileStringExFlags(text, filename,
118119
Py_file_input, NULL, 0);
119120
free(filename);

0 commit comments

Comments
 (0)