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

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
......@@ -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*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment