Skip to content

Commit ac018d3

Browse files
committed
Fix sizeOf in instance Storable Fingerprint
The commit 2d38e16 changed sizeOf (_ :: Fingerprint) from 64 to 14. This is dangerous, because it means that pokeByteOff could be reading Word32 with an offset not divisible by sizeOf (_ :: Word32). Some architectures are forgiving with regards to unaligned reads, some (such as ARM) are not. Let's bump sizeOf (_ :: Fingerprint) from 14 to 16.
1 parent 9a54aaa commit ac018d3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Output/Types.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ fpRaresFold :: (b -> b -> b) -> (Name -> b) -> Fingerprint -> b
267267
fpRaresFold g f Fingerprint{..} = f fpRare1 `g` f fpRare2 `g` f fpRare3
268268

269269
instance Storable Fingerprint where
270-
sizeOf _ = 3*sizeOf name0 + 2
270+
sizeOf _ = 4 * sizeOf name0
271271
alignment _ = 4
272272
peekByteOff ptr i = Fingerprint
273273
<$> peekByteOff ptr (i+0) <*> peekByteOff ptr (i+1*w) <*> peekByteOff ptr (i+2*w)

0 commit comments

Comments
 (0)