summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2024-04-07 20:23:26 +0100
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-04-08 23:16:25 +0200
commite7bb3a52067c426eedffddf86e7d5f0903562da2 (patch)
treea655ee4aed8ceedc61dde01f68619f7202344045 /sd
parentc16f7ca43bb338f23895733ee499505ee6a6e72e (diff)
cid#1596254 Null pointer dereferences in GetSotStorageStream
Re-arrange the calling convention to make it obvious that a valid stream is the same as a good (true) result. Change-Id: I974b023a8e7231e70ab649628fdbe43c33001e5b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165874 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd')
-rw-r--r--sd/source/ui/view/sdview3.cxx36
1 files changed, 11 insertions, 25 deletions
diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx
index c14010708079..a9e82b3ec4b7 100644
--- a/sd/source/ui/view/sdview3.cxx
+++ b/sd/source/ui/view/sdview3.cxx
@@ -321,9 +321,7 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
// ImageMap?
if( !pOwnData && aDataHelper.HasFormat( SotClipboardFormatId::SVIM ) )
{
- std::unique_ptr<SvStream> xStm;
-
- if( aDataHelper.GetSotStorageStream( SotClipboardFormatId::SVIM, xStm ) )
+ if (std::unique_ptr<SvStream> xStm = aDataHelper.GetSotStorageStream( SotClipboardFormatId::SVIM ) )
{
pImageMap.reset(new ImageMap);
// mba: clipboard always must contain absolute URLs (could be from alien source)
@@ -340,9 +338,8 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
if( ( bIsRTF || aDataHelper.HasFormat( SotClipboardFormatId::RICHTEXT ) )
&& ! aDataHelper.HasFormat( SotClipboardFormatId::DRAWING ) )
{
- std::unique_ptr<SvStream> xStm;
-
- if( aDataHelper.GetSotStorageStream( bIsRTF ? SotClipboardFormatId::RTF : SotClipboardFormatId::RICHTEXT, xStm ) )
+ auto nFormatId = bIsRTF ? SotClipboardFormatId::RTF : SotClipboardFormatId::RICHTEXT;
+ if (std::unique_ptr<SvStream> xStm = aDataHelper.GetSotStorageStream( nFormatId ))
{
xStm->Seek( 0 );
@@ -684,8 +681,7 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
if(!bReturn && CHECK_FORMAT_TRANS( SotClipboardFormatId::PDF ))
{
- std::unique_ptr<SvStream> xStm;
- if( aDataHelper.GetSotStorageStream( SotClipboardFormatId::PDF, xStm ) )
+ if (std::unique_ptr<SvStream> xStm = aDataHelper.GetSotStorageStream( SotClipboardFormatId::PDF ))
{
Point aInsertPos(rPos);
Graphic aGraphic;
@@ -704,9 +700,7 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
if(!bReturn && CHECK_FORMAT_TRANS( SotClipboardFormatId::DRAWING ))
{
- std::unique_ptr<SvStream> xStm;
-
- if( aDataHelper.GetSotStorageStream( SotClipboardFormatId::DRAWING, xStm ) )
+ if (std::unique_ptr<SvStream> xStm = aDataHelper.GetSotStorageStream( SotClipboardFormatId::DRAWING ))
{
DrawDocShellRef xShell = new DrawDocShell(SfxObjectCreateMode::INTERNAL, false, DocumentType::Impress);
xShell->DoInitNew();
@@ -1226,9 +1220,7 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
if(!bReturn && (!bLink || pPickObj) && CHECK_FORMAT_TRANS(SotClipboardFormatId::SVXB))
{
- std::unique_ptr<SvStream> xStm;
-
- if( aDataHelper.GetSotStorageStream( SotClipboardFormatId::SVXB, xStm ) )
+ if (std::unique_ptr<SvStream> xStm = aDataHelper.GetSotStorageStream( SotClipboardFormatId::SVXB ))
{
Point aInsertPos( rPos );
Graphic aGraphic;
@@ -1415,9 +1407,7 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
if(!bReturn && !bLink && CHECK_FORMAT_TRANS(SotClipboardFormatId::HTML))
{
- std::unique_ptr<SvStream> xStm;
-
- if( aDataHelper.GetSotStorageStream( SotClipboardFormatId::HTML, xStm ) )
+ if (std::unique_ptr<SvStream> xStm = aDataHelper.GetSotStorageStream( SotClipboardFormatId::HTML ))
{
xStm->Seek( 0 );
// mba: clipboard always must contain absolute URLs (could be from alien source)
@@ -1427,8 +1417,7 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
if(!bReturn && !bLink && CHECK_FORMAT_TRANS(SotClipboardFormatId::EDITENGINE_ODF_TEXT_FLAT))
{
- std::unique_ptr<SvStream> xStm;
- if( aDataHelper.GetSotStorageStream( SotClipboardFormatId::EDITENGINE_ODF_TEXT_FLAT, xStm ) )
+ if (std::unique_ptr<SvStream> xStm = aDataHelper.GetSotStorageStream( SotClipboardFormatId::EDITENGINE_ODF_TEXT_FLAT ))
{
OutlinerView* pOLV = GetTextEditOutlinerView();
@@ -1458,9 +1447,8 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
bool bIsRTF = CHECK_FORMAT_TRANS(SotClipboardFormatId::RTF);
if (bIsRTF || CHECK_FORMAT_TRANS(SotClipboardFormatId::RICHTEXT))
{
- std::unique_ptr<SvStream> xStm;
-
- if( aDataHelper.GetSotStorageStream( bIsRTF ? SotClipboardFormatId::RTF : SotClipboardFormatId::RICHTEXT, xStm ) )
+ auto nFormatId = bIsRTF ? SotClipboardFormatId::RTF : SotClipboardFormatId::RICHTEXT;
+ if (std::unique_ptr<SvStream> xStm = aDataHelper.GetSotStorageStream( nFormatId ))
{
xStm->Seek( 0 );
@@ -1495,9 +1483,7 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
bool bIsHtmlSimple = CHECK_FORMAT_TRANS(SotClipboardFormatId::HTML_SIMPLE);
if (bIsHtmlSimple)
{
- std::unique_ptr<SvStream> xStm;
-
- if (aDataHelper.GetSotStorageStream(SotClipboardFormatId::HTML_SIMPLE, xStm))
+ if (std::unique_ptr<SvStream> xStm = aDataHelper.GetSotStorageStream(SotClipboardFormatId::HTML_SIMPLE))
{
xStm->Seek(0);