Skip to content

Commit 1cb4218

Browse files
colinloveclaude
andcommitted
Fix legacy alias path parsing when no null terminator present
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 3a2aa87 commit 1cb4218

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎acd/l5x/elements.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1918,7 +1918,13 @@ def _legacy_data_type(self, record: LegacyRxGeneric) -> str:
19181918
return atomic_types.get(record.main_record.runtime_type & 0xFF, "")
19191919

19201920
def _legacy_alias_for(self, value: bytes) -> str:
1921-
if len(value) % 2 or not value.endswith(b"\x00\x00"):
1921+
# Usually null-terminated (a trailing b"\x00\x00" utf-16 code unit),
1922+
# but observed on real project files without one -- a path ending in
1923+
# a literal ".<member/bit>" reference (e.g. an alias into a bit or an
1924+
# array/structure member) can occupy the field's full length with no
1925+
# terminator at all. The length just needs to be a whole number of
1926+
# utf-16 code units; a missing terminator isn't itself invalid.
1927+
if len(value) % 2:
19221928
raise ValueError("Invalid legacy alias path")
19231929
path = value.decode("utf-16-le").rstrip("\x00")
19241930

0 commit comments

Comments
 (0)