Browse Source

stb_image.h: apply mainstream PR/1736

Fix root-cause of CVE-2021-45340 : dereference of NULL ptr.
Patch authored by Henner Zeller <[email protected]>
Mainstream pull request: https://github.com/nothings/stb/pull/1736

(cherry picked from commit b5ed0d0138a5467a3812af957c138b695bab31ed)
Ozkan Sezer 3 months ago
parent
commit
6cd14660cf
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/video/stb_image.h

+ 2 - 1
src/video/stb_image.h

@@ -100,7 +100,7 @@ RECENT REVISION HISTORY:
  Bug & warning fixes
  Bug & warning fixes
     Marc LeBlanc            David Woo          Guillaume George     Martins Mozeiko
     Marc LeBlanc            David Woo          Guillaume George     Martins Mozeiko
     Christpher Lloyd        Jerry Jansson      Joseph Thomson       Blazej Dariusz Roszkowski
     Christpher Lloyd        Jerry Jansson      Joseph Thomson       Blazej Dariusz Roszkowski
-    Phil Jordan                                Dave Moore           Roy Eltham
+    Phil Jordan             Henner Zeller      Dave Moore           Roy Eltham
     Hayaki Saito            Nathan Reed        Won Chun
     Hayaki Saito            Nathan Reed        Won Chun
     Luke Graham             Johan Duparc       Nick Verigakis       the Horde3D community
     Luke Graham             Johan Duparc       Nick Verigakis       the Horde3D community
     Thomas Ruf              Ronny Chevalier                         github:rlyeh
     Thomas Ruf              Ronny Chevalier                         github:rlyeh
@@ -1914,6 +1914,7 @@ static unsigned char *stbi__convert_format(unsigned char *data, int img_n, int r
    int i,j;
    int i,j;
    unsigned char *good;
    unsigned char *good;
 
 
+   if (data == NULL) return data;
    if (req_comp == img_n) return data;
    if (req_comp == img_n) return data;
    STBI_ASSERT(req_comp >= 1 && req_comp <= 4);
    STBI_ASSERT(req_comp >= 1 && req_comp <= 4);