summaryrefslogtreecommitdiff
path: root/sc/source/ui/dbgui/dbnamdlg.cxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-03-12 16:05:37 +0100
committerStephan Bergmann <sbergman@redhat.com>2014-03-12 16:24:43 +0100
commit2acdcb2374e448371b173feb03650d8d6db8aba2 (patch)
tree41f165802b60786e854d3f2f13d9639df81ac1d8 /sc/source/ui/dbgui/dbnamdlg.cxx
parent54b4add66698f94e875379bcfc6c76b72488fd7b (diff)
coverity#1158232 Fix ownership of NamedDBs::insert argument
f70d03436b7b501e0ed1d745935a204b9b97b855 "coverity#1158232 have a stab at silencing warning with function markup" claimed that NamedDBs::insert always takes ownerhip of its argument, but boost::ptr_set::insert(std::auto_ptr<U> x) simply calls insert(x.release()), so only takes ownership when it returns true. ScDBDocFunc::AddDBRange (sc/source/ui/docshell/dbdocfun.cxx) relies on this behavior, deleting the argument when insert failed. ScDBDocFunc::RenameDBRange (sc/source/ui/docshell/dbdocfun.cxx) relied on this behavior, deleting the argument when insert failed, until f55cc330dec0dec60c755e2ce28a840c7fca1956 "Fixed the fallout of the changes in ScDBCollection" removed the delete (presumably in error?). I put it back in now. All other uses of NamedDBs::insert ignored the return value (witnessed with SAL_WARN_UNUSED_RESULT). Some are insert-if-not-found cases, where I added asserts now (Sc10Import::LoadDataBaseCollection, sc/source/filter/starcalc/scflt.cxx, is not entirely clear to me, so I added a TODO), while others would have potentially leaked the argument, in which cases I fixed the code. Change-Id: Iad40fbeb625c8ce6b0a61cbf16298d71cdc7de80
Diffstat (limited to 'sc/source/ui/dbgui/dbnamdlg.cxx')
-rw-r--r--sc/source/ui/dbgui/dbnamdlg.cxx7
1 files changed, 6 insertions, 1 deletions
diff --git a/sc/source/ui/dbgui/dbnamdlg.cxx b/sc/source/ui/dbgui/dbnamdlg.cxx
index b1d01b33f484..ba4e781af7e1 100644
--- a/sc/source/ui/dbgui/dbnamdlg.cxx
+++ b/sc/source/ui/dbgui/dbnamdlg.cxx
@@ -17,6 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <cassert>
+
#include <comphelper/string.hxx>
#include <vcl/msgbox.hxx>
@@ -469,7 +473,8 @@ IMPL_LINK_NOARG(ScDbNameDlg, AddBtnHdl)
pNewEntry->SetKeepFmt( m_pBtnKeepFmt->IsChecked() );
pNewEntry->SetStripData( m_pBtnStripData->IsChecked() );
- aLocalDbCol.getNamedDBs().insert(pNewEntry);
+ bool ins = aLocalDbCol.getNamedDBs().insert(pNewEntry);
+ assert(ins); (void)ins;
}
UpdateNames();