diff options
-rw-r--r-- | vcl/source/filter/webp/reader.cxx | 6 | ||||
-rw-r--r-- | vcl/source/filter/webp/writer.cxx | 6 |
2 files changed, 4 insertions, 8 deletions
diff --git a/vcl/source/filter/webp/reader.cxx b/vcl/source/filter/webp/reader.cxx index e8c885053965..5ec8fa4870c2 100644 --- a/vcl/source/filter/webp/reader.cxx +++ b/vcl/source/filter/webp/reader.cxx @@ -26,6 +26,7 @@ #include <sal/log.hxx> #include <unotools/configmgr.hxx> #include <svdata.hxx> +#include <comphelper/scopeguard.hxx> #include <webp/decode.h> @@ -59,10 +60,7 @@ static bool readWebp(SvStream& stream, Graphic& graphic) SAL_WARN("vcl.filter.webp", "WebPInitDecoderConfig() failed"); return false; } - // This unique_ptr is here just to ensure WebPFreeDecBuffer() is called at the end, - // it doesn't actually own the data as such. - std::unique_ptr<WebPDecBuffer, decltype(&WebPFreeDecBuffer)> freeBuffer(&config.output, - WebPFreeDecBuffer); + comphelper::ScopeGuard freeBuffer([&config]() { WebPFreeDecBuffer(&config.output); }); std::vector<uint8_t> data; if (!readWebpInfo(stream, data, config.input)) return false; diff --git a/vcl/source/filter/webp/writer.cxx b/vcl/source/filter/webp/writer.cxx index 32da25e93ca3..b1ac654d858a 100644 --- a/vcl/source/filter/webp/writer.cxx +++ b/vcl/source/filter/webp/writer.cxx @@ -17,11 +17,11 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <memory> #include <vcl/graph.hxx> #include <tools/stream.hxx> #include <filter/WebpWriter.hxx> #include <vcl/BitmapReadAccess.hxx> +#include <comphelper/scopeguard.hxx> #include <sal/log.hxx> #include <webp/encode.h> @@ -87,9 +87,7 @@ static bool writeWebp(SvStream& rStream, const BitmapEx& bitmapEx, bool lossless picture.width = width; picture.height = height; picture.use_argb = lossless ? 1 : 0; // libwebp recommends argb only for lossless - // This unique_ptr is here just to ensure WebPPictureFree() is called at the end, - // it doesn't actually own the data as such. - std::unique_ptr<WebPPicture, decltype(&WebPPictureFree)> freePicture(&picture, WebPPictureFree); + comphelper::ScopeGuard freePicture([&picture]() { WebPPictureFree(&picture); }); // Apparently libwebp needs the entire image data at once in WebPPicture, // so allocate it and copy there. |