[PATCH] D46816: [llvm-rc] Read the Planes/BitCount fields from BITMAPINFOHEADER for icons
Adrian McCarthy via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 14 14:39:54 PDT 2018
amccarth added inline comments.
================
Comment at: tools/llvm-rc/ResourceFileWriter.cpp:950
+ } else {
+ // A PNG .ico file.
+ // https://blogs.msdn.microsoft.com/oldnewthing/20101022-00/?p=12473
----------------
mstorsjo wrote:
> amccarth wrote:
> > Is there a more-specific test to make sure this is a PNG icon and nut just a corrupted file? For example, BMPHeader->biCompression should have a special value for PNG.
> For png, this actually isn't a bmpheader at all, but the png header. I could check if the size field (the first field of the struct) matches the png magic interpreted as ulittle32_t.
There are three possibilities: BMP, PNG, or the wrong type of file. The original change tested to see if it was a valid BMP and assumed PNG otherwise, discounting the possibility that it could be neither. This just flips that around.
If we're going to ignore the possibility of a corrupt/incorrect input, then the original code was clearer, since it was actually testing the size.
https://reviews.llvm.org/D46816
More information about the llvm-commits
mailing list