Skip to content

Commit

Permalink
lzma: realloc dictionary only to extend it
Browse files Browse the repository at this point in the history
Otherwise, we can spend much time in useless reallocs
which do not increase the siez of lzma dictionary.
  • Loading branch information
catenacyber authored and victorjulien committed Apr 16, 2022
1 parent 80f6c40 commit 32216ff
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions htp/lzma/LzmaDec.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,15 +634,15 @@ static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte
if (limit - p->dicPos > rem) {
if (p->dicBufSize < p->prop.dicSize) {
p->dicBufSize = p->prop.dicSize;
if (p->dicBufSize > memlimit) {
return SZ_ERROR_MEM;
}
Byte *tmp = realloc(p->dic, p->dicBufSize);
if (!tmp) {
return SZ_ERROR_MEM;
}
p->dic = tmp;
}
if (p->dicBufSize > memlimit) {
return SZ_ERROR_MEM;
}
Byte *tmp = realloc(p->dic, p->dicBufSize);
if (!tmp) {
return SZ_ERROR_MEM;
}
p->dic = tmp;
limit2 = p->dicPos + rem;
}

Expand Down

0 comments on commit 32216ff

Please sign in to comment.