Skip to content

Commit

Permalink
Fix memory leak of input_image in ktxTexture2_CompressAstcEx
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkCallow committed Jun 21, 2023
1 parent dd671e8 commit fa1fe4d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/astc_encode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,21 +688,21 @@ ktxTexture2_CompressAstcEx(ktxTexture2* This, ktxAstcParams* params) {

launchThreads(threadCount, compressionWorkloadRunner, &work);

buffer_out += levelImageSizeOut;

// Reset ASTC context for next image
astcenc_compress_reset(astc_context);
offset += levelImageSizeIn;

imageFree(input_image);

if (work.error != ASTCENC_SUCCESS) {
std::cout << "ASTC compressor failed\n" <<
astcenc_get_error_string(work.error) << std::endl;

imageFree(input_image);

astcenc_context_free(astc_context);
return KTX_INVALID_OPERATION;
}

buffer_out += levelImageSizeOut;

// Reset ASTC context for next image
astcenc_compress_reset(astc_context);
offset += levelImageSizeIn;
}
}

Expand Down

0 comments on commit fa1fe4d

Please sign in to comment.