ImagingDataCommons / libdicom

C library for reading DICOM files
https://libdicom.readthedocs.io
MIT License
16 stars 8 forks source link

dict: embed item structs in hash entries #71

Closed bgilbert closed 12 months ago

bgilbert commented 12 months ago

Instead of duplicating an item struct's fields in the hash entry struct that wraps it, add the entire item struct as a field of the hash entry. This eliminates casts and ensures the type system understands what we're doing.

Fixes strict aliasing violations in dcm_init(): we were assigning through a cast and then immediately reading through the original pointer. This happened to cause segfaults on RHEL 9 aarch64, but any compiler would be entitled to optimize away the read.

Also rename some variables to clarify that they're not _hash_entry structs.

jcupitt commented 12 months ago

Thanks!