Skip to content

Commit 10533de

Browse files
authored
fix: Fix UB-sanitizer warning about alignment (#5097)
Signed-off-by: Larry Gritz <lg@larrygritz.com>
1 parent 4413110 commit 10533de

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/libOpenImageIO/exif.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -826,10 +826,11 @@ read_exif_tag(ImageSpec& spec, const TIFFDirEntry* dirp, cspan<uint8_t> buf,
826826
const TagMap& exif_tagmap(exif_tagmap_ref());
827827
const TagMap& gps_tagmap(gps_tagmap_ref());
828828

829-
// Make a copy of the pointed-to TIFF directory, swab the components
830-
// if necessary.
829+
// Make a copy of the pointed-to TIFF directory, swab the components if
830+
// necessary. We have to do this as a memcpy rather than an assignment
831+
// because the pointer we're copying from may not be properly aligned.
831832
TIFFDirEntry dir;
832-
memcpy(&dir, dirp, sizeof(TIFFDirEntry));
833+
memcpy(&dir, (const void*)dirp, sizeof(TIFFDirEntry));
833834
unsigned int unswapped_tdir_offset = dir.tdir_offset;
834835
if (swab) {
835836
swap_endian(&dir.tdir_tag);

0 commit comments

Comments
 (0)