Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#312 closed defect (fixed)

dev_areca.cpp:146: sanity check after use - doesn't look right ?

Reported by: dcb314 Owned by: Christian Franke
Priority: major Milestone: Release 6.3
Component: all Version: 6.2
Keywords: Cc:

Description

I just ran the static analyser cppcheck over the source
code of version 6.2

It said many things, including

[dev_areca.cpp:146] -> [dev_areca.cpp:148]: (warning) Array 'cmds[5]' accessed at index 5, which is out of bounds. Otherwise condition 'arcmsr_cmd>=5' is redundant.

Source code is

sBuf.srbioctl.ControlCode? = cmds[arcmsr_cmd];

if(arcmsr_cmd >= ARCMSR_CMD_TOTAL)
{

return -1;

}

Suggest move sanity check to before use.

Change History (4)

comment:1 Changed 9 years ago by Christian Franke

Milestone: Release 6.3
Owner: changed from somebody to Christian Franke
Status: newaccepted

comment:2 Changed 9 years ago by Christian Franke

Resolution: fixed
Status: acceptedclosed

comment:3 Changed 9 years ago by Christian Franke

Should be now fixed on trunc. More cppcheck related fixes will follow.

Interestingly I could not reproduce the (reasonable) warning message you mentioned. I used "cppcheck --enable=all --inconclusive --force dev_areca.cpp" with cppcheck 1.54 and 1.63 on dev_areca.cpp from 6.2.

comment:4 in reply to:  3 Changed 9 years ago by dcb314

Replying to chrfranke:

Interestingly I could not reproduce the (reasonable) warning message you mentioned.

I use cppcheck trunk development code, via svn.

Note: See TracTickets for help on using tickets.