Hello,
Cppcheck reported this:
[basic/source/comp/dim.cxx:1239]: (error) Dereferencing 'pDef' after it is
deallocated / released
We have this:
1213 pProc = pOld->GetProcDef();
1214 if( !pProc )
1215 {
1216 // Declared as a variable
1217 Error( SbERR_BAD_DECLARATION, pDef->GetName() );
1218 delete pDef;
1219 pProc = NULL;
1220 bError_ = true;
1221 }
1222 // #100027: Multiple declaration -> Error
1223 // #112787: Not for setup, REMOVE for 8
1224 else if( pProc->IsUsedForProcDecl() )
1225 {
1226 PropertyMode ePropMode = pDef->getPropertyMode();
1227 if( ePropMode == PROPERTY_MODE_NONE || ePropMode ==
pProc->getPropertyMode() )
1228 {
1229 Error( SbERR_PROC_DEFINED, pDef->GetName() );
1230 delete pDef;
1231 pProc = NULL;
1232 bError_ = true;
1233 }
1234 }
1235
1236 if( !bError_ )
1237 {
1238 pDef->Match( pProc );
1239 pProc = pDef;
1240 }
See http://opengrok.libreoffice.org/xref/core/basic/source/comp/dim.cxx#1209
So it seems a false positive since when pDef is deleted, bError = true and
we don't enter the if.
But isn't it weird to have each time
delete pDef;
pProc = NULL;
Shouldn't it be one of these :
1)
delete pProc;
pProc = NULL;
2)
delete pDef;
pDef = NULL;
?
Julien
--
View this message in context:
http://nabble.documentfoundation.org/Cppcheck-Dereferencing-pDef-after-it-is-deallocated-released-basic-module-tp4139045.html
Sent from the Dev mailing list archive at Nabble.com.
Context
- Cppcheck: Dereferencing 'pDef' after it is deallocated / released (basic module) · julien2412
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.