Skip to content

Commit

Permalink
Fix undefined behaviour in datetime.time.fromisoformat() (python#111982)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
Yhg1s authored Nov 11, 2023
1 parent 38035fe commit 21615f7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Modules/_datetimemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -4630,7 +4630,7 @@ time_fromisoformat(PyObject *cls, PyObject *tstr) {
}

int hour = 0, minute = 0, second = 0, microsecond = 0;
int tzoffset, tzimicrosecond = 0;
int tzoffset = 0, tzimicrosecond = 0;
int rv = parse_isoformat_time(p, len,
&hour, &minute, &second, &microsecond,
&tzoffset, &tzimicrosecond);
Expand Down

0 comments on commit 21615f7

Please sign in to comment.