Commit 30870ef9 authored by Dimitri van Heesch's avatar Dimitri van Heesch
Browse files

Bug 735982 - [PATCH] Fix potential allocation of huge memory amount due to...

Bug 735982 - [PATCH] Fix potential allocation of huge memory amount due to type overflow in src/lodepng.cpp
parent 68aa8c2b
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -4125,9 +4125,12 @@ unsigned LodePNG_loadFile(unsigned char** out, size_t* outsize, const char* file
  rewind(file);
  
  /*read contents of the file into the vector*/
  if (size>0)
  {
    *outsize = 0;
    *out = (unsigned char*)malloc((size_t)size);
    if(size && (*out)) (*outsize) = fread(*out, 1, (size_t)size, file);
  }

  fclose(file);
  if(!(*out) && size) return 80; /*the above malloc failed*/