Index: sword-1.5.9/src/modules/common/zverse.cpp =================================================================== --- sword-1.5.9.orig/src/modules/common/zverse.cpp 2005-11-20 06:06:40.000000000 +0000 +++ sword-1.5.9/src/modules/common/zverse.cpp 2006-12-08 14:10:02.000000000 +0000 @@ -257,13 +257,12 @@ void zVerse::zReadText(char testmt, long start, unsigned short size, SWBuf &inBuf) { inBuf = ""; - inBuf.setFillByte(0); - inBuf.setSize(size+1); - if (size > 0) { - if (cacheBuf) - strncpy(inBuf.getRawData(), &(cacheBuf[start]), size); + if ( (size > 0) && cacheBuf && ((unsigned)(start+size) <= strlen(cacheBuf)) ){ //TODO: optimize this, remove strlen + inBuf.setFillByte(0); + inBuf.setSize(size+1); + strncpy(inBuf.getRawData(), &(cacheBuf[start]), size); + inBuf.setSize(strlen(inBuf.c_str())); } - inBuf.setSize(strlen(inBuf.c_str())); } Index: sword-1.5.9/src/modules/common/zipcomprs.cpp =================================================================== --- sword-1.5.9.orig/src/modules/common/zipcomprs.cpp 2003-06-27 02:41:08.000000000 +0100 +++ sword-1.5.9/src/modules/common/zipcomprs.cpp 2006-12-08 13:14:15.000000000 +0000 @@ -79,7 +79,7 @@ if (len) { //printf("Doing compress\n"); - if (compress((Bytef*)zbuf, &zlen, (const Bytef*)buf, len)!=Z_OK) + if (compress((Bytef*)zbuf, &zlen, (const Bytef*)buf, len) != Z_OK) { printf("ERROR in compression\n"); } @@ -89,7 +89,7 @@ } else { - fprintf(stderr, "No buffer to compress\n"); + fprintf(stderr, "ERROR: no buffer to compress\n"); } delete [] zbuf; free (buf); @@ -144,15 +144,18 @@ unsigned long blen = zlen*20; // trust compression is less than 1000% char *buf = new char[blen]; //printf("Doing decompress {%s}\n", zbuf); - if (uncompress((Bytef*)buf, &blen, (Bytef*)zbuf, zlen) != Z_OK) { - fprintf(stderr, "no room in outbuffer to during decompression. see zipcomp.cpp\n"); + slen = 0; + switch (uncompress((Bytef*)buf, &blen, (Bytef*)zbuf, zlen)){ + case Z_OK: SendChars(buf, blen); slen = blen; break; + case Z_MEM_ERROR: fprintf(stderr, "ERROR: not enough memory during decompression.\n"); break; + case Z_BUF_ERROR: fprintf(stderr, "ERROR: not enough room in the out buffer during decompression.\n"); break; + case Z_DATA_ERROR: fprintf(stderr, "ERROR: corrupt data during decompression.\n"); break; + default: fprintf(stderr, "ERROR: an unknown error occured during decompression.\n"); break; } - SendChars(buf, blen); delete [] buf; - slen = blen; } else { - fprintf(stderr, "No buffer to decompress!\n"); + fprintf(stderr, "ERROR: no buffer to decompress!\n"); } //printf("Finished decoding\n"); free (zbuf); Index: sword-1.5.9/src/modules/common/entriesblk.cpp =================================================================== --- sword-1.5.9.orig/src/modules/common/entriesblk.cpp 2006-12-08 14:10:16.000000000 +0000 +++ sword-1.5.9/src/modules/common/entriesblk.cpp 2006-12-08 14:10:38.000000000 +0000 @@ -10,8 +10,13 @@ // offset(4); size(4); EntriesBlock::EntriesBlock(const char *iBlock, unsigned long size) { - block = (char *)calloc(1, size); - memcpy(block, iBlock, size); + if (size) { + block = (char *)calloc(1, size); + memcpy(block, iBlock, size); + } + else { + block = (char *)calloc(1, sizeof(__u32)); + } }