What changed, and why it matters
This is a tiny follow-up patch that widens a type check in Electrum's wallet database code. When deleting or removing an item from a stored dictionary, the code now clears the parent pointer for any 'base stored object' rather than only for nested dictionaries. Without this fix, other stored object types (such as lists) might keep a stale reference to their former parent, which could lead to inconsistent database state or unexpected behavior when the data is later modified and saved.
Treat as a low-risk correctness fix. Review the preceding commit to understand the full context, run wallet database regression tests, and include in normal release testing. No urgent security response is indicated by this diff alone.
Security signals we found
Data-integrity fix in persistence layer
Reference lifecycle correction after deletion
Follow-up to an immediately preceding commit (suggests a related issue was being addressed)
Evidence from the diff
In StoredDict.delitem and StoredDict.pop, the guard around r._parent = None was changed from isinstance(r, StoredDict) to isinstance(r, BaseStoredObject). BaseStoredObject is the common base class for StoredDict and StoredList (and likely StoredObject). The previous narrower check meant that removing a StoredList (or similar non-dict stored object) from a StoredDict did not detach its _parent, so subsequent writes on the child could still propagate to the parent’s database through the stored object’s reference chain. This is a data-integrity/correctness fix in the JSON DB layer.
Changed components
electrum/json_db.pyStoredDict.__delitem__StoredDict.popInspect captured patch +2 / −2
diff --git a/electrum/json_db.py b/electrum/json_db.py
index e0c0ecb..cfad514 100644
--- a/electrum/json_db.py
+++ b/electrum/json_db.py
@@ -225,7 +225,7 @@ class StoredDict(dict, BaseStoredObject):
r = self.get(key, None)
dict.__delitem__(self, key)
self.db_remove(key)
- if isinstance(r, StoredDict):
+ if isinstance(r, BaseStoredObject):
r._parent = None
@locked
@@ -238,7 +238,7 @@ class StoredDict(dict, BaseStoredObject):
return v
r = dict.pop(self, key)
self.db_remove(key)
- if isinstance(r, StoredDict):
+ if isinstance(r, BaseStoredObject):
r._parent = None
return r
Why this scored 27/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.