Use nullptr for passing a null pointer to crc32
ClosedPublic

Authored by aacid on Jan 28 2018, 9:30 PM.

Details

Summary

I'm a bit unconvinced, wihtout it we get a warning if we enable -Wzero-as-null-pointer-constant
but using Z_NULL seems to be more "what the library wants"

If we don't want this, this would be a reason against enabling -Wzero-as-null-pointer-constant
for all the frameworks as i've suggested in the other review

Diff Detail

Repository
R243 KArchive
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
aacid created this revision.Jan 28 2018, 9:30 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptJan 28 2018, 9:30 PM
Restricted Application added a subscriber: Frameworks. · View Herald Transcript
aacid requested review of this revision.Jan 28 2018, 9:30 PM
mpyne accepted this revision.Mar 6 2018, 2:13 AM
mpyne added a subscriber: mpyne.

Actually -Wzero-as-null-pointer-constant is probably a good idea, and this is a correct fix. A decade ago when everything was going from 32 to 64-bits, we ran into a JuK crash bug because we used GST_NULL (or similar) as the null constant for a gstreamer variadic C function, which in C++ mode was 0. Well, C++ didn't know that the 0 was supposed to be a pointer instead of an int, so the function in question crashed because C++ put a 32-bit int on the stack instead of a 64-bit null pointer.

Using nullptr consistently solves this issue, even though it wouldn't be a problem here since C++ can see that the 0 is supposed to convert to a pointer.

The real fix should probably go in zlib, but I wouldn't hold my breath due to the compatibility requirements that I would imagine they maintain.

This revision is now accepted and ready to land.Mar 6 2018, 2:13 AM
This revision was automatically updated to reflect the committed changes.