This issue comes from a Codex global scan of deepmodeling/tbplas at commit 4d3652b.
Severity: Medium
HopDict.__setitem__() copies the matrix into _hoppings before checking whether (0, 0, 0) contains forbidden diagonal onsite terms. If _check_diag() raises and the caller catches the exception, the invalid matrix remains stored in the object.
Code reference:
|
# Set hopping matrix |
|
# We copy the hopping matrix to avoid changing it accidentally. |
|
self._hoppings[rn] = hop_mat.copy() |
|
|
|
# Check for diagonal terms |
|
if rn == (0, 0, 0): |
|
self._check_diag() |
Suggested fix: validate the candidate matrix before assigning it to _hoppings, or roll back the assignment when validation fails.
This issue comes from a Codex global scan of deepmodeling/tbplas at commit 4d3652b.
Severity: Medium
HopDict.__setitem__()copies the matrix into_hoppingsbefore checking whether(0, 0, 0)contains forbidden diagonal onsite terms. If_check_diag()raises and the caller catches the exception, the invalid matrix remains stored in the object.Code reference:
tbplas/tbplas/builder/base.py
Lines 542 to 548 in 4d3652b
Suggested fix: validate the candidate matrix before assigning it to
_hoppings, or roll back the assignment when validation fails.