Skip Vptr checks when the pointer value is null.
In general static_cast on null pointers causes undefined behaviors, it may not depending on the contexts. This patch enforces to skip null pointers just like it was done in -fsanitize=null.
Differential D4412
[UBsan] Skip -fsanitize=vptr instrumentations when the pointer value is null byoungyoung on Jul 7 2014, 1:59 PM. Authored by
Details
Diff Detail Event TimelineComment Actions Please provide a test.
Comment Actions Expanded a comment, and added a testcase. I'm not sure whether the checks in the testcase would be enough, so please let me know if it doesn't.
Comment Actions Update the patch as commented except the test cast folding. Richard, could you please point which file should I fold into for the testcase? As far as I checked, all existing ubsan tests are written in C (except type-blacklist one), but this case has to be done in C++. Comment Actions rsmith@ - could you please land this patch as I don't have a commit permission?
|
Instead of the below fix, please instead fix this by changing this line to