Skip to content

Commit 881dc1d

Browse files
committed
pythongh-120713: moved buffer declaration to the same scope as the ptoappend pointer
1 parent c54739b commit 881dc1d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Modules/_datetimemodule.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1851,6 +1851,11 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
18511851
const char *ptoappend; /* ptr to string to append to output buffer */
18521852
Py_ssize_t ntoappend; /* # of bytes to append to output buffer */
18531853

1854+
#ifdef NORMALIZE_CENTURY
1855+
/* Buffer of maximum size of formatted year permitted by long. */
1856+
char buf[SIZEOF_LONG*5/2+2];
1857+
#endif
1858+
18541859
assert(object && format && timetuple);
18551860
assert(PyUnicode_Check(format));
18561861
/* Convert the input format to a C string and size */
@@ -1976,11 +1981,7 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
19761981
}
19771982
}
19781983

1979-
/* Maximum size of formatted year permitted by long. */
1980-
#define MAX_YEAR_BUFFER_LEN SIZEOF_LONG*5/2+2
1981-
char buf[MAX_YEAR_BUFFER_LEN];
1982-
1983-
ntoappend = PyOS_snprintf(buf, MAX_YEAR_BUFFER_LEN, "%04ld", year_long);
1984+
ntoappend = PyOS_snprintf(buf, sizeof(buf), "%04ld", year_long);
19841985
ptoappend = buf;
19851986
}
19861987
#endif

0 commit comments

Comments
 (0)