Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#12 [cppcheck] Possible null pointer dereference: t

closed-fixed
None
7
2011-07-05
2011-01-21
orbitcowboy
No

During a check of the current git-head of qfsm with the static code analysis tool cppcheck, the tool discoverd a possible nullponter dereference in file UndoBuffer.cpp at line 182.

Lets take a look at the code:

void UndoBuffer::changeTransition(GTransition* t)
{
....
if (t) // <-- (1)
{
oldstart = (GState*)t->getStart();
oldend = (GState*)t->getEnd();
}
....
*tmp = *t; // <-- (2)
.....
}

(1) Here is checked wheter t is null or not. If it is null the if-block will not exectued.
(2) A few lines later (182) the pointer is dereferenced. If it is null, the application will crash.

If you are interested, cppcheck is open-source and also available on sourceforge.

Best regards from the cppcheck team and many thanks for the great work you have done developing such a great finite state machine drawing tool

Ettl Martin

Discussion

  • orbitcowboy
    orbitcowboy
    2011-01-21

    • priority: 5 --> 7
     
  • Stefan Duffner
    Stefan Duffner
    2011-07-05

    • assigned_to: nobody --> sttodu
    • status: open --> closed-fixed