| | |
| | | *_miplevels = (header->dwCaps & DDSCAPS_MIPMAP) ? header->dwMipMapCount : 1; |
| | | |
| | | unsigned int calculatedMipLevels = uintLog2(MAX(width, height)) + 1; |
| | | if (*_miplevels > 32) |
| | | { |
| | | // too many mip levels, width and height would be larger than 32-bit int |
| | | // file is corrupted |
| | | return 0; |
| | | } |
| | | else if (*_miplevels == 0) |
| | | if (*_miplevels == 0) |
| | | { |
| | | // invalid, calculate it ourselves from size |
| | | *_miplevels = calculatedMipLevels; |
| | | } |
| | | else if (*_miplevels > calculatedMipLevels) |
| | | { |
| | | // too many mip levels, several would be 1x1 |
| | | // file is corrupted |
| | | return 0; |
| | | } |
| | | |
| | | if (header->ddspf.dwFlags & DDPF_FOURCC) |
| | | { |