Menu

False positive with BugHunt

2021-04-17
2021-04-18
  • Dave Nadler

    Dave Nadler - 2021-04-17

    I got a bazillion of these (for an extremely common pattern in many
    projects):

    memset(alarmObjects, 0, sizeof(alarmObjects));

    (error) Buffer read/write, when calling 'memset' it cannot be determined
    that 1st argument is not overflowed [bughuntingBufferOverflow]

    HTH!
    Best Regards, Dave

    --
    Dave Nadler, USA East Coast voice (978) 263-0097, drn@nadler.com, Skype
    Dave.Nadler1

     
  • Alexander Mai

    Alexander Mai - 2021-04-18

    I thought it might suffer from some strange declaration, but I can confirm it for

    int alarmObjects[42];
    void foo() {
      memset(alarmObjects, 0, sizeof(alarmObjects));
    }
    

    as well.
    I've created https://trac.cppcheck.net/ticket/10250 therefore.

     
  • Dave Nadler

    Dave Nadler - 2021-04-18

    Thanks Alexander! Very nice '42' ;-)

     

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.