vcl/source/filter/graphicfilter.cxx | 2 -- vcl/source/filter/jpeg/Exif.cxx | 17 ++++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-)
New commits: commit c15f5d20714214d6e6fd6c213b7f2d056b6c0ef0 Author: Mike Kaganski <[email protected]> AuthorDate: Wed Oct 1 13:40:15 2025 +0200 Commit: Mike Kaganski <[email protected]> CommitDate: Wed Oct 1 14:47:14 2025 +0200 Related: tdf#168634 Make Exif::processJpeg restore endianness Generalize the fix from commit bae6c3ac004111965754e71dbb0a97adc034b0d9 (tdf#168634 Exif::processJpeg unhelpfully changes the endianness of the stream, 2025-10-01). Change-Id: I95fb62553bc5a71cc1a599594a1a7ef0e23ccf7f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191722 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index 951551f8bfc0..49b385628de6 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -981,7 +981,6 @@ ErrCode GraphicFilter::readJPEG(SvStream & rStream, Graphic & rGraphic, GfxLinkT // Get Orientation from EXIF data GraphicNativeMetadata aMetadata; - SvStreamEndian aOriginalEndianness(rStream.GetEndian()); if (aMetadata.read(rStream)) { Degree10 aRotation = aMetadata.getRotation(); @@ -991,7 +990,6 @@ ErrCode GraphicFilter::readJPEG(SvStream & rStream, Graphic & rGraphic, GfxLinkT aTransform.rotate(aRotation); } } - rStream.SetEndian(aOriginalEndianness); return aReturnCode; } diff --git a/vcl/source/filter/jpeg/Exif.cxx b/vcl/source/filter/jpeg/Exif.cxx index 469281bdcc85..32871b889e32 100644 --- a/vcl/source/filter/jpeg/Exif.cxx +++ b/vcl/source/filter/jpeg/Exif.cxx @@ -19,6 +19,8 @@ #include "Exif.hxx" #include <memory> + +#include <comphelper/scopeguard.hxx> #include <osl/endian.h> #include <tools/stream.hxx> @@ -65,22 +67,23 @@ Degree10 Exif::getRotation() const bool Exif::read(SvStream& rStream) { - sal_uInt64 nStreamPosition = rStream.Tell(); - bool result = processJpeg(rStream, false); - rStream.Seek( nStreamPosition ); - - return result; + return processJpeg(rStream, false); } void Exif::write(SvStream& rStream) { - sal_uInt64 nStreamPosition = rStream.Tell(); processJpeg(rStream, true); - rStream.Seek( nStreamPosition ); } bool Exif::processJpeg(SvStream& rStream, bool bSetValue) { + comphelper::ScopeGuard restore( + [&rStream, p = rStream.Tell(), e = rStream.GetEndian()] + { + rStream.SetEndian(e); + rStream.Seek(p); + }); + sal_uInt16 aMagic16; sal_uInt16 aLength;
