Menu

#995 Suspicious code in debuggergdb plugin

Undefined
open
nobody
debuggergdb (5)
Undefined
2020-12-29
2020-07-24
No

I am testing the last version of cppcheck, and it warned about this part of parsewatchvalue.cpp:

        if (!class_line.IsValid())
        {
            int *p = NULL;
            *p = 0;
        }
        else
        {
            if (!class_line.Matches(wxT("   +0x000 a                : 10")))
            {
                int *p = NULL;
                *p = 0;
            }
        }

I do not understand the object of this assignments, they will raise an exception.

Discussion

  • Teodor Petrov

    Teodor Petrov - 2020-07-24

    I guess these are the poor man asserts. If I remember correctly there we're cases where the regexp engine didn't support the given expression and this code tests if it actually works. :) I suppose it could be written in a bit better way by logging some message.

    It is low severity and I'm not sure I'll spend time doing it.

     
  • Morten MacFly

    Morten MacFly - 2020-12-29

    I guess a better way would be to simply use wxASSERT here instead.
    @fuscated?

     
  • Morten MacFly

    Morten MacFly - 2020-12-29

    Like this:

    wxASSERT(class_line.IsValid());
    wxASSERT(class_line.Matches(wxT("   +0x000 a                : 10")));
    
     

    Last edit: Morten MacFly 2020-12-29
  • Teodor Petrov

    Teodor Petrov - 2020-12-29

    Or cbAssert...

     
    • Morten MacFly

      Morten MacFly - 2020-12-29

      Hehe... sure. :-)

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.