Skip to content

Commit

Permalink
Fix decompress data missed bug when use sdcard.bz2/* if enable -O2
Browse files Browse the repository at this point in the history
len need initilized before call BZ2_bzBuffToBuffDecompress

Signed-off-by: Frank Li <Frank.Li@nxp.com>
  • Loading branch information
nxpfrankli committed May 28, 2019
1 parent d2fca8f commit acaf035
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions libuuu/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ int bz2_decompress(shared_ptr<FileBuffer> pbz, FileBuffer *p, vector<bz2_blk> *
{
for (int i = start; i < pblk->size(); i += skip)
{
unsigned int len;
unsigned int len = pblk->at(i).decompress_size;
if (i) /*skip first dummy one*/
{
(*pblk)[i].error = BZ2_bzBuffToBuffDecompress((char*)p->data() + pblk->at(i).decompress_offset,
Expand Down Expand Up @@ -613,8 +613,13 @@ int FSBz2::load(string backfile, string filename, FileBuffer *p, bool async)

p->m_aync_thread = thread(bz_async_load, backfile, p);

if (!async)
if (!async) {
p->m_aync_thread.join();
if (!p->m_loaded) {
set_last_err_string("async data load failure\n");
return -1;
}
}

return 0;
}
Expand Down Expand Up @@ -683,6 +688,11 @@ shared_ptr<FileBuffer> get_file_buffer(string filename, bool async)

if(p->m_aync_thread.joinable())
p->m_aync_thread.join();

if(!p->m_loaded)
{
return NULL;
}
}

return p;
Expand Down

0 comments on commit acaf035

Please sign in to comment.