Skip to content

Commit 13cd2bf

Browse files
Yhg1smiss-islington
authored andcommitted
Fix undefined behaviour in datetime.time.fromisoformat() (pythonGH-111982)
Fix undefined behaviour in datetime.time.fromisoformat() when parsing a string without a timezone. 'tzoffset' is not assigned to by parse_isoformat_time if it returns 0, but time_fromisoformat then passes tzoffset to another function, which is undefined behaviour (even if the function in question does not use the value). (cherry picked from commit 21615f7) Co-authored-by: T. Wouters <thomas@python.org>
1 parent cd3e2d3 commit 13cd2bf

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

Modules/_datetimemodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4649,7 +4649,7 @@ time_fromisoformat(PyObject *cls, PyObject *tstr) {
46494649
}
46504650

46514651
int hour = 0, minute = 0, second = 0, microsecond = 0;
4652-
int tzoffset, tzimicrosecond = 0;
4652+
int tzoffset = 0, tzimicrosecond = 0;
46534653
int rv = parse_isoformat_time(p, len,
46544654
&hour, &minute, &second, &microsecond,
46554655
&tzoffset, &tzimicrosecond);

0 commit comments

Comments
 (0)