Skip to content

Commit d780fa7

Browse files
authored
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
1 parent 81328f3 commit d780fa7

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed an instance where a MemoryError within the zoneinfo module might not be reported or not reported at its source. (found by Coverity)

Modules/_zoneinfo.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,13 +278,11 @@ zoneinfo_new(PyTypeObject *type, PyObject *args, PyObject *kw)
278278

279279
instance =
280280
PyObject_CallMethod(weak_cache, "setdefault", "OO", key, tmp);
281-
((PyZoneInfo_ZoneInfo *)instance)->source = SOURCE_CACHE;
282-
283281
Py_DECREF(tmp);
284-
285282
if (instance == NULL) {
286283
return NULL;
287284
}
285+
((PyZoneInfo_ZoneInfo *)instance)->source = SOURCE_CACHE;
288286
}
289287

290288
update_strong_cache(type, key, instance);
@@ -1622,7 +1620,7 @@ parse_abbr(const char *const p, PyObject **abbr)
16221620
}
16231621

16241622
*abbr = PyUnicode_FromStringAndSize(str_start, str_end - str_start);
1625-
if (abbr == NULL) {
1623+
if (*abbr == NULL) {
16261624
return -1;
16271625
}
16281626

0 commit comments

Comments
 (0)