From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Sun, 12 Nov 2023 00:24:02 +0000 (+0100) Subject: [3.11] Fix undefined behaviour in datetime.time.fromisoformat() (GH-111982) (#111991) X-Git-Tag: v3.11.7~74 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5a6d1dbc10878ff2d04b2e0687409855787312ff;p=thirdparty%2FPython%2Fcpython.git [3.11] Fix undefined behaviour in datetime.time.fromisoformat() (GH-111982) (#111991) 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 --- diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index 5c67f38ec211..df0ce722d59a 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -4649,7 +4649,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);