mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Fix null-pointer derefs in reference resolution
Two related bugs in read_from_stream's reference-resolution
loop, both reachable from malformed input:
- has_attribute_value<IfcBaseClass*> only checks the stored
slot's type, not that it's non-null (e.g. an explicit $
value), so the following get_attribute_value() call could
return null and inst->declaration() crashed on it.
- byid_[ref] default-inserts (and returns) a null pointer
when the owning instance id isn't present, which was then
dereferenced unconditionally via ->data().
Added regression tests using the two minimized crash inputs
that found these.
Generated with the assistance of an AI coding tool.
(cherry picked from commit 56121ca061)
This commit is contained in:
@@ -17,3 +17,15 @@ END-ISO-10303-21;
|
||||
f = ifcopenshell.file.from_string(data)
|
||||
print(ifcopenshell.get_log())
|
||||
f.by_id(5)
|
||||
|
||||
|
||||
def test_reference_to_undefined_owning_instance():
|
||||
data = "ISO-10303-21;HEADER;FILE_DESCRIPTION();FILE_NAME();FILE_SCHEMA(('IFC4'));#=IFCRELAGGREGATES((#))#5=IFCPOINT)"
|
||||
ifcopenshell.file.from_string(data)
|
||||
print(ifcopenshell.get_log())
|
||||
|
||||
|
||||
def test_reference_to_undefined_owning_instance_simple_type():
|
||||
data = "ISO-10303-21;HEADER;FILE_DESCRIPTION();FILE_NAME();FILE_SCHEMA(('IFC4'));#=IFCPROJECT((#))#4=IFCSIUNIT("
|
||||
ifcopenshell.file.from_string(data)
|
||||
print(ifcopenshell.get_log())
|
||||
|
||||
Reference in New Issue
Block a user