Fix potential memory leak when writing WebP throws (#2600)

This commit is contained in:
Adrià Arrufat 2022-06-14 20:59:38 +09:00 committed by GitHub
parent 0f1d8e964f
commit 7f46535cce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -74,7 +74,10 @@ namespace dlib {
{
fout.write(reinterpret_cast<char*>(output), output_size);
if (!fout.good())
{
WebPFree(output);
throw image_save_error("Error while writing WebP image to " + filename + ".");
}
}
else
{