diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2024-04-07 20:23:26 +0100 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-04-08 23:16:25 +0200 |
commit | e7bb3a52067c426eedffddf86e7d5f0903562da2 (patch) | |
tree | a655ee4aed8ceedc61dde01f68619f7202344045 /dbaccess | |
parent | c16f7ca43bb338f23895733ee499505ee6a6e72e (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 'dbaccess')
-rw-r--r-- | dbaccess/source/ui/misc/TableCopyHelper.cxx | 15 | ||||
-rw-r--r-- | dbaccess/source/ui/tabledesign/TEditControl.cxx | 5 |
2 files changed, 7 insertions, 13 deletions
diff --git a/dbaccess/source/ui/misc/TableCopyHelper.cxx b/dbaccess/source/ui/misc/TableCopyHelper.cxx index 9da2cb100f3d..5d22c90468c8 100644 --- a/dbaccess/source/ui/misc/TableCopyHelper.cxx +++ b/dbaccess/source/ui/misc/TableCopyHelper.cxx @@ -180,16 +180,15 @@ void OTableCopyHelper::pasteTable( SotClipboardFormatId _nFormatId try { DropDescriptor aTrans; - bool bOk; if ( _nFormatId != SotClipboardFormatId::RTF ) - bOk = _rTransData.GetSotStorageStream(SotClipboardFormatId::HTML ,aTrans.aHtmlRtfStorage); + aTrans.aHtmlRtfStorage = _rTransData.GetSotStorageStream(SotClipboardFormatId::HTML); else - bOk = _rTransData.GetSotStorageStream(SotClipboardFormatId::RTF,aTrans.aHtmlRtfStorage); + aTrans.aHtmlRtfStorage = _rTransData.GetSotStorageStream(SotClipboardFormatId::RTF); aTrans.nType = E_TABLE; aTrans.bHtml = SotClipboardFormatId::HTML == _nFormatId; aTrans.sDefaultTableName = GetTableNameForAppend(); - if ( !bOk || !copyTagTable(aTrans,false,_xConnection) ) + if ( !aTrans.aHtmlRtfStorage || !copyTagTable(aTrans,false,_xConnection) ) m_pController->showError(SQLException(DBA_RES(STR_NO_TABLE_FORMAT_INSIDE), *m_pController, "S1000", 0, Any())); } catch(const SQLException&) @@ -254,16 +253,12 @@ bool OTableCopyHelper::copyTagTable(const TransferableDataHelper& _aDroppedData bool bHtml = _aDroppedData.HasFormat(SotClipboardFormatId::HTML); if ( bHtml || _aDroppedData.HasFormat(SotClipboardFormatId::RTF) ) { - bool bOk; - if ( bHtml ) - bOk = _aDroppedData.GetSotStorageStream(SotClipboardFormatId::HTML ,_rAsyncDrop.aHtmlRtfStorage); - else - bOk = _aDroppedData.GetSotStorageStream(SotClipboardFormatId::RTF,_rAsyncDrop.aHtmlRtfStorage); + _rAsyncDrop.aHtmlRtfStorage = _aDroppedData.GetSotStorageStream(bHtml ? SotClipboardFormatId::HTML : SotClipboardFormatId::RTF); _rAsyncDrop.bHtml = bHtml; _rAsyncDrop.bError = !copyTagTable(_rAsyncDrop,true,_xConnection); - bRet = ( !_rAsyncDrop.bError && bOk && _rAsyncDrop.aHtmlRtfStorage ); + bRet = ( !_rAsyncDrop.bError && _rAsyncDrop.aHtmlRtfStorage ); if ( bRet ) { // now we need to copy the stream diff --git a/dbaccess/source/ui/tabledesign/TEditControl.cxx b/dbaccess/source/ui/tabledesign/TEditControl.cxx index 32e298445e14..b9328604b277 100644 --- a/dbaccess/source/ui/tabledesign/TEditControl.cxx +++ b/dbaccess/source/ui/tabledesign/TEditControl.cxx @@ -770,9 +770,8 @@ void OTableEditorCtrl::InsertRows( sal_Int32 nRow ) TransferableDataHelper aTransferData(TransferableDataHelper::CreateFromSystemClipboard(GetParent())); if(aTransferData.HasFormat(SotClipboardFormatId::SBA_TABED)) { - std::unique_ptr<SvStream> aStreamRef; - bool bOk = aTransferData.GetSotStorageStream(SotClipboardFormatId::SBA_TABED,aStreamRef); - if (bOk && aStreamRef) + std::unique_ptr<SvStream> aStreamRef = aTransferData.GetSotStorageStream(SotClipboardFormatId::SBA_TABED); + if (aStreamRef) { aStreamRef->Seek(STREAM_SEEK_TO_BEGIN); aStreamRef->ResetError(); |