Permalink
Browse files

Bug 735982 - [PATCH] Fix potential allocation of huge memory amount d…

…ue to type overflow in src/lodepng.cpp
  • Loading branch information...
Dimitri van Heesch
Dimitri van Heesch committed Sep 23, 2014
1 parent 68aa8c2 commit 30870ef90f4a74e7c53a6856b10bcd2f16e4d1bd
Showing with 6 additions and 3 deletions.
  1. +6 −3 src/lodepng.cpp
@@ -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*/
*outsize = 0;
*out = (unsigned char*)malloc((size_t)size);
if(size && (*out)) (*outsize) = fread(*out, 1, (size_t)size, file);
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*/

0 comments on commit 30870ef

Please sign in to comment.