[REVIEW][3-5][3-5-1] fdo#46340 add more insanity to SdrGrafObj::getInputStream so it doesn't crash as much
mstahl at redhat.com
Wed Feb 29 13:56:00 PST 2012
propose the following for libreoffice-3-5, which fixes
a crash regression in 3.5 when saving pictures.
before fd95f1ab6220c6a530fd2e4e727417f504a5db51 it used to work this
way: the getInputStream would call one of 3 duplicated GetDocumentStream
methods, which would then create an XInputStream and wrap it in a
SvStream. then getInputStream would wrap that SvStream again in an
during the utl::UcbStreamHelper::CreateStream the
UcbLockBytes::setInputStream_Impl is called, which determines that the
XInputStream is not seekable, and thus decides to copy the stream into a
temp file, and thus the code before my refactoring survived the fact
that the XStorage where the original XInputStream was taken from went
out of scope, invalidating said XInputStream.
if you are thoroughly confused by now, then you have reached an accurate
understanding of the situation.
so this patch just restores the aspects of the previous mis-design that
accidentally prevent the crash.
On 29/02/12 22:37, Michael Stahl wrote:
> svx/source/svdraw/svdograf.cxx | 8 ++++++++
> 1 file changed, 8 insertions(+)
> New commits:
> commit 0c6d89941118368ccbb596362a545db5d3a07dbe
> Author: Michael Stahl <mstahl at redhat.com>
> Date: Wed Feb 29 22:34:51 2012 +0100
> fdo#46340: fix crash in SdrGrafObj::getInputStream:
> Add the ridiculous hack that used to be here (and distributed across
> various GetDocumentStream methods to make it non-obvious)
> that makes this not crash by accident.
> (regression from fd95f1ab6220c6a530fd2e4e727417f504a5db51)
> diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
> index 23f81df..6fd9cf3 100644
> --- a/svx/source/svdraw/svdograf.cxx
> +++ b/svx/source/svdraw/svdograf.cxx
> @@ -1335,6 +1335,14 @@ Reference< XInputStream > SdrGrafObj::getInputStream()
> ::comphelper::LifecycleProxy proxy;
> pModel->GetDocumentStream(pGraphic->GetUserData(), proxy));
> + // fdo#46340: this may look completely insane, and it is,
> + // but it also prevents a crash: the LifecycleProxy will go out
> + // of scope, but the xStream must be returned; the UcbStreamHelper
> + // will actually copy the xStream to a temp file (because it is
> + // not seekable), which makes it not crash...
> + SvStream *const pStream =
> + utl::UcbStreamHelper::CreateStream(xStream);
> + xStream.set(new utl::OInputStreamWrapper(pStream, true));
> else if( pGraphic && GetGraphic().IsLink() )
More information about the LibreOffice