Revert "This fixes strange decompression errors"

This reverts commit b1bf40b04d.
This commit is contained in:
Lubos Dolezel 2017-03-25 17:59:11 +01:00
parent b1bf40b04d
commit 4929db6f7b
2 changed files with 11 additions and 14 deletions

View File

@ -16,16 +16,13 @@ PbzxReader::PbzxReader(std::shared_ptr<Reader> reader)
m_lastFlags = be64toh(m_lastFlags);
m_compressedOffset = 12;
m_strm = new lzma_stream;
memset(m_strm, 0, sizeof(*m_strm));
if (lzma_stream_decoder(m_strm, UINT64_MAX, LZMA_CONCATENATED) != LZMA_OK)
if (lzma_stream_decoder(&m_strm, UINT64_MAX, LZMA_CONCATENATED) != LZMA_OK)
throw std::runtime_error("lzma init error");
}
PbzxReader::~PbzxReader()
{
lzma_end(m_strm);
lzma_end(&m_strm);
}
bool PbzxReader::isPbzx(std::shared_ptr<Reader> reader)
@ -47,14 +44,14 @@ int32_t PbzxReader::read(void* buf, int32_t count, uint64_t offset)
uint32_t done = 0;
m_strm->next_out = static_cast<uint8_t*>(buf);
m_strm->avail_out = count;
m_strm.next_out = static_cast<uint8_t*>(buf);
m_strm.avail_out = count;
while (m_strm->avail_out > 0)
while (m_strm.avail_out > 0)
{
int status;
if (!m_strm->avail_in)
if (!m_strm.avail_in)
{
if (!m_remainingRunLength)
{
@ -82,16 +79,16 @@ int32_t PbzxReader::read(void* buf, int32_t count, uint64_t offset)
m_compressedOffset += rd;
m_remainingRunLength -= rd;
m_strm->next_in = reinterpret_cast<const uint8_t*>(m_buffer);
m_strm->avail_in = rd;
m_strm.next_in = reinterpret_cast<const uint8_t*>(m_buffer);
m_strm.avail_in = rd;
}
status = lzma_code(m_strm, LZMA_RUN);
status = lzma_code(&m_strm, LZMA_RUN);
if (status != LZMA_OK)
throw std::runtime_error("lzma decompression error");
}
done = count - m_strm->avail_out;
done = count - m_strm.avail_out;
m_lastReadEnd += done;
return done;

View File

@ -13,7 +13,7 @@ public:
static bool isPbzx(std::shared_ptr<Reader> reader);
private:
lzma_stream* m_strm;
lzma_stream m_strm = LZMA_STREAM_INIT;
uint64_t m_remainingRunLength = 0, m_lastFlags;
};