mm2 / Little-CMS

A free, open source, CMM engine. It provides fast transforms between ICC profiles.
https://www.littlecms.com
MIT License
549 stars 174 forks source link

add NULL check for mpe in Type_LUT8_Write #410

Closed x2018 closed 10 months ago

x2018 commented 10 months ago

Fix a potential NULL dereference just like below:

==3959==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000008 (pc 0x0000006eaa47 bp 0x7fff68d66050 sp 0x7fff68d65d80 T0)
==3959==The signal is caused by a READ memory access.
==3959==Hint: address points to the zero page.
    #0 0x6eaa47 in Type_LUT8_Write Little-CMS-lcms2.15/src/cmstypes.c:1927:15
    #1 0x65610c in SaveTags Little-CMS-lcms2.15/src/cmsio0.c:1380:18
    #2 0x6548eb in cmsSaveProfileToIOhandler Little-CMS-lcms2.15/src/cmsio0.c:1453:10
    #3 0x656c0a in cmsSaveProfileToMem Little-CMS-lcms2.15/src/cmsio0.c:1539:11

This fix refers to the code of Type_LUT16_Write().