Skip to content

Commit e64780b

Browse files
committed
pythongh-120713: fixed scope for formatted year buffer
1 parent 9fd3d2d commit e64780b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Modules/_datetimemodule.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,6 +1837,7 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
18371837
PyObject *colonzreplacement = NULL; /* py string, replacement for %:z */
18381838
PyObject *Zreplacement = NULL; /* py string, replacement for %Z */
18391839
PyObject *freplacement = NULL; /* py string, replacement for %f */
1840+
char year_formatted[5]; /* formatted year with century for %Y */
18401841

18411842
const char *pin; /* pointer to next char in input format */
18421843
Py_ssize_t flen; /* length of input format */
@@ -1942,10 +1943,9 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
19421943
#ifdef NORMALIZE_CENTURY
19431944
else if (ch == 'Y') {
19441945
/* 0-pad year with century on platforms that do not do so */
1945-
char formatted[5];
1946-
ntoappend = sprintf(formatted, "%04ld",
1946+
ntoappend = sprintf(year_formatted, "%04ld",
19471947
PyLong_AsLong(PyTuple_GET_ITEM(timetuple, 0)));
1948-
ptoappend = formatted;
1948+
ptoappend = year_formatted;
19491949
}
19501950
#endif
19511951
else {

0 commit comments

Comments
 (0)