Skip to content

Commit 713c16e

Browse files
authored
gh-101703: Use PyOS_snprintf in _freeze_module (#161871)
1 parent 9b633f5 commit 713c16e

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
@@ -122,11 +122,12 @@ read_text(const char *inpath)
122122
static PyObject *
123123
compile_and_marshal(const char *name, const char *text)
124124
{
125-
char *filename = (char *) malloc(strlen(name) + 10);
125+
int text_size = strlen(name) + 10;
126+
char *filename = (char *) malloc(text_size);
126127
if (filename == NULL) {
127128
return PyErr_NoMemory();
128129
}
129-
sprintf(filename, "<frozen %s>", name);
130+
PyOS_snprintf(filename, text_size, "<frozen %s>", name);
130131
PyObject *code = Py_CompileStringExFlags(text, filename,
131132
Py_file_input, NULL, 0);
132133
free(filename);

0 commit comments

Comments
 (0)