Skip to content

Commit

Permalink
Fix Proto2ES Zlib Compression (#1269)
Browse files Browse the repository at this point in the history
Pass the correct dataSize to EnigmaStruct images which is the size of the image data compressed.
  • Loading branch information
RobertBColton committed Jun 7, 2018
1 parent 53d9a2f commit 4c20a19
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions CommandLine/emake/Proto2ES.cpp
Expand Up @@ -237,13 +237,15 @@ std::string Actions2Code(const ::google::protobuf::RepeatedPtrField< buffers::re

#include <zlib.h>

unsigned char* zlib_compress(unsigned char* inbuffer,int actualsize)
unsigned char* zlib_compress(unsigned char* inbuffer,int &actualsize)
{
uLongf outsize=(int)(actualsize*1.1)+12;
Bytef* outbytef=new Bytef[outsize];

compress(outbytef,&outsize,(Bytef*)inbuffer,actualsize);

actualsize = outsize;

return (unsigned char*)outbytef;
}

Expand Down Expand Up @@ -281,8 +283,8 @@ Image AddImage(const std::string fname) {
free(image);
i.width = pngwidth;
i.height = pngheight;
i.data = reinterpret_cast<char*>(zlib_compress(bitmap, bitmap_size));
i.dataSize = bitmap_size;
i.data = reinterpret_cast<char*>(zlib_compress(bitmap, i.dataSize));

return i;
}
Expand Down

0 comments on commit 4c20a19

Please sign in to comment.