Skip to content

Commit

Permalink
Betsy: Fix stack-use-after-scope when using BC3 and BC5
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyqiu committed Dec 19, 2024
1 parent fafc073 commit b447eaa
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions modules/betsy/image_compress_betsy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ Error BetsyCompressor::_compress(BetsyFormat p_format, Image *r_img) {
}
}

RID *dst_texture_rid = &dst_texture_primary;
RID dst_texture_rid = dst_texture_primary;

if (needs_alpha_block) {
// Set the destination texture width and size.
Expand Down Expand Up @@ -638,21 +638,21 @@ Error BetsyCompressor::_compress(BetsyFormat p_format, Image *r_img) {
compress_rd->sync();
}

dst_texture_rid = &dst_texture_combined;
dst_texture_rid = dst_texture_combined;

compress_rd->free(dst_texture_primary);
compress_rd->free(dst_texture_alpha);
}

// Copy data from the GPU to the buffer.
const Vector<uint8_t> texture_data = compress_rd->texture_get_data(*dst_texture_rid, 0);
const Vector<uint8_t> texture_data = compress_rd->texture_get_data(dst_texture_rid, 0);
int64_t dst_ofs = Image::get_image_mipmap_offset(r_img->get_width(), r_img->get_height(), dest_format, i);

memcpy(dst_data_ptr + dst_ofs, texture_data.ptr(), texture_data.size());

// Free the source and dest texture.
compress_rd->free(src_texture);
compress_rd->free(*dst_texture_rid);
compress_rd->free(dst_texture_rid);
}

src_images.clear();
Expand Down

0 comments on commit b447eaa

Please sign in to comment.