Closed bobsayshilol closed 4 years ago
Thanks for fixing, that issue indeed showed up with "-fsanitize=undefined" and is fixed with this
I did another change to this to allow representing the invalid values in the enum: commit 165dfcffddc4bb31d32b90edc56bfb971ead9390
This to be able to store invalid values of corrupt PNGs in this enum as well (but without having names for those values, but they can still be printf'd to diagnose corrupt PNGs this way)
Thanks! I considered doing it both ways, but picked the restricted values because I prefer to be explicit about what's accepted vs what's not, though it did make the code a little bit messier doing it that way. Both are valid, so no complaints here.
Without a fixed underlying type, the range of LodePNGColorType is [0, 8) since all the values can be represented by 3 bits. This means that the cast from an arbitrary unsigned char to a LodePNGColorType in lodepng_inspect() is not valid for values not in that range. To fix this we check that the colour type is valid before casting it to a LodePNGColorType so that all LodePNGColorType instances are valid.