Merge pull request #8416 from IntelOrca/required-images-extra-checks

Add extra checks in required image code
This commit is contained in:
Ted John 2018-12-10 22:42:43 +00:00 committed by GitHub
commit 6837e29584
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -55,7 +55,7 @@ namespace ObjectJsonHelpers
{
auto length = g1_calculate_data_size(&orig);
g1 = orig;
g1.offset = (uint8_t*)std::malloc(length);
g1.offset = new uint8_t[length];
std::memcpy(g1.offset, orig.offset, length);
g1.flags &= ~G1_FLAG_HAS_ZOOM_SPRITE;
}
@ -67,9 +67,9 @@ namespace ObjectJsonHelpers
{
auto length = g1_calculate_data_size(orig);
g1 = *orig;
g1.offset = (uint8_t*)std::malloc(length);
g1.offset = new uint8_t[length];
std::memcpy(g1.offset, orig->offset, length);
if (g1.flags & G1_FLAG_HAS_ZOOM_SPRITE)
if ((g1.flags & G1_FLAG_HAS_ZOOM_SPRITE) && g1.zoomed_offset != 0)
{
// Fetch image for next zoom level
next_zoom = std::make_unique<RequiredImage>((uint32_t)(idx - g1.zoomed_offset), getter);
@ -84,7 +84,7 @@ namespace ObjectJsonHelpers
~RequiredImage()
{
std::free(g1.offset);
delete[] g1.offset;
}
};