Page MenuHome

DNA: Fix ASan warning when reading large uint64_t value

Authored by Julian Eisel (Severin) on Sep 8 2020, 5:30 PM.



When casting we would store the member value as double, which if large
enough would be interpreted as negative double. When assigning that
negative value to an unsigned type, ASan would complain:

blender/software/dev/default/src/source/blender/makesdna/intern/dna_genfile.c:884:9: runtime error: -1.07374e+09 is outside the range of representable values of type 'long unsigned int'

(I kept getting this on startup)

Use a large enough unsigned integer type instead to hold the value.

Diff Detail

rB Blender
temp-dna-uint64-fix (branched from master)
Build Status
Buildable 10058
Build 10058: arc lint + arc unit

Event Timeline

Julian Eisel (Severin) requested review of this revision.Sep 8 2020, 5:30 PM
Julian Eisel (Severin) created this revision.
Julian Eisel (Severin) edited the summary of this revision. (Show Details)Sep 8 2020, 5:32 PM
Julian Eisel (Severin) edited the summary of this revision. (Show Details)
Brecht Van Lommel (brecht) requested changes to this revision.Sep 8 2020, 7:44 PM

I think that if you cast float to double, it would get rounded now?

This revision now requires changes to proceed.Sep 8 2020, 7:44 PM