[PATCH] avoid Possible null pointer dereference in linguistic/source/spelldsp.hxx
julien2412
serval2412 at yahoo.fr
Sat Feb 11 07:21:44 PST 2012
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 ?
(if yes, I can commit and push it on master)
Julien.
--
View this message in context: http://nabble.documentfoundation.org/PATCH-avoid-Possible-null-pointer-dereference-in-linguistic-source-spelldsp-hxx-tp3735163p3735163.html
Sent from the Dev mailing list archive at Nabble.com.
More information about the LibreOffice
mailing list