diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-11-12 00:39:03 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-12 00:39:03 (GMT) |
commit | 1afc4dc3e6b95d4a23cdcbe2ebebe1d0ba09f0f4 (patch) | |
tree | ff4d1539d04da2d62a23e2e49d05caf7be794309 | |
parent | 0f7671cc6963db087cb99354b03999bde5b1d2dd (diff) | |
download | cpython-1afc4dc3e6b95d4a23cdcbe2ebebe1d0ba09f0f4.zip cpython-1afc4dc3e6b95d4a23cdcbe2ebebe1d0ba09f0f4.tar.gz cpython-1afc4dc3e6b95d4a23cdcbe2ebebe1d0ba09f0f4.tar.bz2 |
[3.12] Fix undefined behaviour in datetime.time.fromisoformat() (GH-111982) (#111992)
Fix undefined behaviour in datetime.time.fromisoformat() (GH-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 21615f77b5a580e83589abae618dbe7c298700e2)
Co-authored-by: T. Wouters <thomas@python.org>
-rw-r--r-- | Modules/_datetimemodule.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index d8183c6..c8dbc75 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -4620,7 +4620,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, µsecond, &tzoffset, &tzimicrosecond); |