diff --git a/src/file.cpp b/src/file.cpp index f49594e0..edfb4ff0 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -259,12 +259,14 @@ int InputFile::readx(void *buf, int len) int InputFile::read(MemBuffer *buf, int len) { + buf->checkState(); assert((unsigned)len <= buf->getSize()); return read(buf->getVoidPtr(), len); } int InputFile::readx(MemBuffer *buf, int len) { + buf->checkState(); assert((unsigned)len <= buf->getSize()); return read(buf->getVoidPtr(), len); } @@ -371,6 +373,7 @@ void OutputFile::write(const void *buf, int len) void OutputFile::write(const MemBuffer *buf, int len) { + buf->checkState(); assert((unsigned)len <= buf->getSize()); write(buf->getVoidPtr(), len); } diff --git a/src/packer.cpp b/src/packer.cpp index d5f657ee..398da7d0 100644 --- a/src/packer.cpp +++ b/src/packer.cpp @@ -382,6 +382,7 @@ void Packer::verifyOverlappingDecompression() return; memmove(obuf + offset, obuf, ph.c_len); decompress(obuf + offset, obuf, true); + obuf.checkState(); #endif /* !UNUPX */ } @@ -488,6 +489,7 @@ void Packer::copyOverlay(OutputFile *fo, unsigned overlay, { assert((int)overlay >= 0); assert((off_t)overlay < file_size); + buf->checkState(); if (!fo || overlay == 0) return; if (opt->overlay != opt->COPY_OVERLAY) @@ -512,6 +514,7 @@ void Packer::copyOverlay(OutputFile *fo, unsigned overlay, fo->write(buf, len); overlay -= len; } while (overlay > 0); + buf->checkState(); } @@ -1263,6 +1266,8 @@ void Packer::compressWithFilters(Filter *parm_ft, { for (int i = 0; i < nfilters; i++) // for all filters { + ibuf.checkState(); + obuf.checkState(); // get fresh packheader ph = orig_ph; ph.method = methods[m]; @@ -1347,6 +1352,9 @@ void Packer::compressWithFilters(Filter *parm_ft, // restore ibuf[] - unfilter with verify ft.unfilter(ibuf + filter_off, filter_len, true); // + ibuf.checkState(); + obuf.checkState(); + // if (strategy < 0) break; }