summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorT. Wouters <thomas@python.org>2023-11-11 23:56:27 (GMT)
committerGitHub <noreply@github.com>2023-11-11 23:56:27 (GMT)
commit21615f77b5a580e83589abae618dbe7c298700e2 (patch)
treebff2f57f9477d5113b69373b9c8d1301434fb1ea /Modules
parent38035fed9ba543d587c1fbba5c463d34edf3aff9 (diff)
downloadcpython-21615f77b5a580e83589abae618dbe7c298700e2.zip
cpython-21615f77b5a580e83589abae618dbe7c298700e2.tar.gz
cpython-21615f77b5a580e83589abae618dbe7c298700e2.tar.bz2
Fix undefined behaviour in datetime.time.fromisoformat() (#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).
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_datetimemodule.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
index 9938ed5..cb5403e 100644
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -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);