[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/sdk/kdevelop/languages/cpp/parser/rpp
From:       Milian Wolff <mail () milianw ! de>
Date:       2010-04-07 23:40:18
Message-ID: 20100407234018.7FC97AC88F () svn ! kde ! org
[Download RAW message or body]

SVN commit 1112370 by mwolff:

don't access uninitialized memory and always go the 'no cache' route for the first \
call of LocationTable::positionAt

 M  +5 -1      pp-location.cpp  


--- trunk/extragear/sdk/kdevelop/languages/cpp/parser/rpp/pp-location.cpp \
#1112369:1112370 @@ -33,11 +33,13 @@
 }
 
 LocationTable::LocationTable()
+  : m_positionAtLastOffset(-1)
 {
   anchor(0, Anchor(0,0), 0);
 }
 
 LocationTable::LocationTable(const PreprocessedContents& contents)
+  : m_positionAtLastOffset(-1)
 {
   anchor(0, Anchor(0,0), 0);
 
@@ -53,7 +55,9 @@
 {
   AnchorInTable ret = anchorForOffset(offset, collapseIfMacroExpansion);
 
-  if (m_lastAnchorInTable == ret && offset >= m_positionAtLastOffset) {
+  // NOTE: when m_positionAtLastOffset == -1 we have not used the cache yet
+  // and all the members of m_lastAnchorInTable will be uninitialized.
+  if (m_positionAtLastOffset != -1 && m_lastAnchorInTable == ret && offset >= \
m_positionAtLastOffset) {  // use cached position
     ret.anchor.column = m_positionAtColumnCache;
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic