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

List:       kde-bugs-dist
Subject:    [kate] [Bug 318468] Kate crashed while editing a php file with highlighting set to xml
From:       Dima Ryazanov <dima () gmail ! com>
Date:       2013-05-01 3:34:23
Message-ID: bug-318468-17878-D1xnr4f8HT () http ! bugs ! kde ! org/
[Download RAW message or body]

https://bugs.kde.org/show_bug.cgi?id=318468

--- Comment #7 from Dima Ryazanov <dima@gmail.com> ---
I took a look a the code in katesyntaxmanager.cpp. This function looks up
"name" in "hlDict":

QString KateHlManager::identifierForName(const QString& name)
{
  KateHighlighting *hl = 0;

  if ((hl = hlDict[name]))
    return hl->getIdentifier ();

  return QString();
}

According to the QHash documentation, if the key does not exist, it will be
created with a default value:

"If the hash contains no item with the key, the function inserts a
default-constructed value into the hash with the key, and returns a reference
to it. If the hash contains multiple items with the key, this function returns
a reference to the most recently inserted value."

So if name wasn't in hlDict, then hlDict[name] will now contain a NULL.

Then, the "nameForIdentifier" function will dereference the NULL pointer:

   if ( (*it)->getIdentifier() == identifier ) {
      return it.key();
   }

Wouldn't this explain the crash?

-- 
You are receiving this mail because:
You are watching all bug changes.
[prev in list] [next in list] [prev in thread] [next in thread] 

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