Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions Lib/test/test_zoneinfo/test_zoneinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1559,22 +1559,9 @@ def test_weak_cache_descriptor_use_after_free(self):
if "UTC" not in available_zones:
Comment thread
fatelei marked this conversation as resolved.
Outdated
raise unittest.SkipTest("No time zone data available")

class Cache:
def __init__(self):
self.data = {}

def get(self, key, default=None):
return self.data.get(key, default)

def setdefault(self, key, default):
return self.data.setdefault(key, default)

def clear(self, *args, **kwargs):
self.data.clear()

class BombDescriptor:
def __get__(self, obj, owner):
return Cache()
return dict()
Comment thread
fatelei marked this conversation as resolved.
Outdated

class EvilZoneInfo(ZoneInfo):
Comment thread
fatelei marked this conversation as resolved.
Outdated
Comment thread
serhiy-storchaka marked this conversation as resolved.
Outdated
pass
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
Fix zoneinfo use-after-free with descriptor _weak_cache. Return new
reference from get_weak_cache() instead of borrowed reference to prevent
premature object free.
Fix zoneinfo use-after-free with descriptor _weak_cache. a descriptor as _weak_cache could cause crashes during object creation. The fix ensures proper reference counting for descriptor-provided objects.
Loading