Hello,
Il 11/02/2012 16:21, julien2412 ha scritto:
Hello,
Cppcheck reports this :
[spelldsp.hxx:138]: (error) Possible null pointer dereference: pCache -
otherwise it is redundant to check if pCache is null at line 136
Here are the lines :
134 inline linguistic::SpellCache& SpellCheckerDispatcher::GetCache()
const
135 {
136 if (!pCache)
137 ((SpellCheckerDispatcher *) this)->pCache = new
linguistic::SpellCache();
138 return *pCache;
139 }
Here is a simple (naive ?) patch
diff --git a/linguistic/source/spelldsp.hxx b/linguistic/source/spelldsp.hxx
index 9ae9cd4..34ac28f 100644
--- a/linguistic/source/spelldsp.hxx
+++ b/linguistic/source/spelldsp.hxx
@@ -134,8 +134,11 @@ public:
inline linguistic::SpellCache& SpellCheckerDispatcher::GetCache() const
{
if (!pCache)
+ {
((SpellCheckerDispatcher *) this)->pCache = new
linguistic::SpellCache();
- return *pCache;
+ return *pCache;
+ }
+ return NULL;
Is it ok ?
It looks wrong to me, i'm really not into C++ but it seems
((SpellCheckerDispatcher *) this)->pCache should be the same pCache you
are dereferencing later. In any case you should not return NULL if
pCache is something else, no?
What about this?
if (pCache)
return *pCache;
return ((SpellCheckerDispatcher *) this)->pCache = new
linguistic::SpellCache();
cheers,
--
Riccardo Magliocchetti
Context
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.