diff options
author | Gregory P. Smith <greg@krypto.org> | 2020-06-22 07:39:28 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-22 07:39:28 (GMT) |
commit | d780fa7931d8ce94994827232d7cca79b0be3bf1 (patch) | |
tree | 1953bde8cd8d55482b4a48fc9ea8c7f17e94cf6d /Modules/_zoneinfo.c | |
parent | 81328f30703bd7225e7e73aedb0994a7293ce190 (diff) | |
download | cpython-d780fa7931d8ce94994827232d7cca79b0be3bf1.zip cpython-d780fa7931d8ce94994827232d7cca79b0be3bf1.tar.gz cpython-d780fa7931d8ce94994827232d7cca79b0be3bf1.tar.bz2 |
bpo-41056: Fix a possible MemoryError leak within zoneinfo. (GH-21007)
This was detected by our Coverity scan as a REVERSE_INULL issue.
Automerge-Triggered-By: @gpshead
Diffstat (limited to 'Modules/_zoneinfo.c')
-rw-r--r-- | Modules/_zoneinfo.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/Modules/_zoneinfo.c b/Modules/_zoneinfo.c index e8b2831..a288349 100644 --- a/Modules/_zoneinfo.c +++ b/Modules/_zoneinfo.c @@ -278,13 +278,11 @@ zoneinfo_new(PyTypeObject *type, PyObject *args, PyObject *kw) instance = PyObject_CallMethod(weak_cache, "setdefault", "OO", key, tmp); - ((PyZoneInfo_ZoneInfo *)instance)->source = SOURCE_CACHE; - Py_DECREF(tmp); - if (instance == NULL) { return NULL; } + ((PyZoneInfo_ZoneInfo *)instance)->source = SOURCE_CACHE; } update_strong_cache(type, key, instance); @@ -1622,7 +1620,7 @@ parse_abbr(const char *const p, PyObject **abbr) } *abbr = PyUnicode_FromStringAndSize(str_start, str_end - str_start); - if (abbr == NULL) { + if (*abbr == NULL) { return -1; } |