Weekly cppcheck run against Aug 27 Git Tree

chris ahrendt celticht32 at yahoo.com
Thu Aug 27 21:18:42 CDT 2009





----- Original Message ----
From: Ben Klein <shacklein at gmail.com>
To: chris ahrendt <celticht32 at yahoo.com>
Cc: wine-devel at winehq.org
Sent: Thursday, August 27, 2009 10:06:56 PM
Subject: Re: Weekly cppcheck run against Aug 27 Git Tree

2009/8/28 chris ahrendt <celticht32 at yahoo.com>:
> Mike Kaplinskiy wrote:
>> On Thu, Aug 27, 2009 at 3:52 PM, chris ahrendt<celticht32 at yahoo.com> wrote:
>>
>>> This is the result of running cppcheck 1.35 with the --all parm against
>>> the august 27th Git tree:
>>>
>>> [../wine-git/dlls/dbghelp/msc.c:88]: (possible error) Array index out of
>>> bounds
>>> [../wine-git/dlls/dbghelp/msc.c:89]: (possible error) Array index out of
>>> bounds
>>>
>>
>> False positive, apparently the numbers are hardcoded as:
>> 72     char        msg[128];
>> 88         msg[10 + 3 * 16] = ' '; // = 58<127
>> 89         msg[10 + 3 * 16 + 1 + 16] = '\0'; // = 75<127
>
> Mike While yes the hard coded one above is a false positive... I would
> argue its still a bug that probably needs to get fixed...

>I don't follow this logic. How is it a bug (in Wine) exactly?

I thought one of the programming standards was the fact you don't hard code values IE 10+3*16... 
it should probably be :

msg_blank = 10+3*16; // These go into header files
msg_length = 128; // This goes into header file

char msg[msg_length];
memset(msg, 0, sizeof(msg));
memset(msg, ' ', msg_blank); // or it could even be msg[msg_blank] = ' '; if only position 58 needs to be a ' ' , but I prefer the first method.

does pretty much the same thing except for one point.
Whatever is in the local stack at the point of assigning the msg buffer will be still there unless you initialise it to null.

chris



      



More information about the wine-devel mailing list