Skip to content

Commit

Permalink
Bug 735982 - [PATCH] Fix potential allocation of huge memory amount d…
Browse files Browse the repository at this point in the history
…ue to type overflow in src/lodepng.cpp
  • Loading branch information
Dimitri van Heesch committed Sep 23, 2014
1 parent 68aa8c2 commit 30870ef
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/lodepng.cpp
Expand Up @@ -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*/
Expand Down

0 comments on commit 30870ef

Please sign in to comment.