From 166a2b8a438b742bad236ee0acd4caf62dfa4835 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 30 Jul 2006 04:53:06 +0000 Subject: [PATCH] fixed bug where disk size was written without the header included --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%4040 --- sourcepawn/compiler/pawncc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sourcepawn/compiler/pawncc.c b/sourcepawn/compiler/pawncc.c index d8073e2d..1727e5c2 100644 --- a/sourcepawn/compiler/pawncc.c +++ b/sourcepawn/compiler/pawncc.c @@ -584,6 +584,7 @@ int main(int argc, char *argv[]) size_t size; Bytef *zcmp; uLong disksize; + size_t header_size; int err = Z_OK; /* reuse this memory block! */ @@ -600,8 +601,9 @@ int main(int argc, char *argv[]) (unsigned char *)pOrig->base + sizeof(sp_file_hdr_t), pHdr->dataoffs - sizeof(sp_file_hdr_t)); - size = pHdr->imagesize - pHdr->dataoffs; - proper = (unsigned char *)pOrig->base + pHdr->dataoffs; + header_size = pHdr->dataoffs; + size = pHdr->imagesize - header_size; + proper = (unsigned char *)pOrig->base + header_size; /* get initial size estimate */ pHdr->disksize = (uint32_t)compressBound(pHdr->imagesize); @@ -621,11 +623,11 @@ int main(int argc, char *argv[]) proper, size); } else { - pHdr->disksize = (uint32_t)disksize; + pHdr->disksize = (uint32_t)disksize + header_size; pHdr->compression = SPFILE_COMPRESSION_GZ; memfile_write(bin_file, (unsigned char *)zcmp, - pHdr->disksize); + disksize); free(zcmp); } }