upx_lzma_test_overlap cleanup
This commit is contained in:
+11
-9
@@ -508,15 +508,17 @@ int upx_lzma_test_overlap ( const upx_bytep buf, unsigned src_off,
|
|||||||
unsigned const overlap_overhead = src_off + src_len - dlen;
|
unsigned const overlap_overhead = src_off + src_len - dlen;
|
||||||
// printf("upx_lzma_test_overlap: %d\n", overlap_overhead);
|
// printf("upx_lzma_test_overlap: %d\n", overlap_overhead);
|
||||||
|
|
||||||
upx_bytep const dst = (upx_bytep)malloc(overlap_overhead + dlen);
|
upx_bytep const dst = (upx_bytep)malloc(src_off + src_len);
|
||||||
upx_bytep const src = (overlap_overhead + dlen + dst) - src_len;
|
if (dst) {
|
||||||
// High end of src aligns with high end of dst (including overlap_overhead).
|
upx_bytep const src = &dst[src_off];
|
||||||
memcpy(src, &buf[src_off], src_len);
|
// High ends of src and dst are equal (including overlap_overhead.)
|
||||||
int const rv = upx_lzma_decompress(src, src_len, dst, &dlen,
|
memcpy(src, &buf[src_off], src_len);
|
||||||
method, cresult);
|
int const rv = upx_lzma_decompress(src, src_len, dst, &dlen,
|
||||||
free(dst);
|
method, cresult);
|
||||||
if (UPX_E_OK==rv) {
|
free(dst);
|
||||||
return UPX_E_OK;
|
if (UPX_E_OK==rv) {
|
||||||
|
return UPX_E_OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return UPX_E_ERROR;
|
return UPX_E_ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user