[PATCH] fixed if check before strchr

Juan Lang juan.lang at gmail.com
Tue May 6 15:06:34 CDT 2008


On Tue, May 6, 2008 at 1:00 PM, Eric Pouech <eric.pouech at orange.fr> wrote:
> Marcus Meissner a écrit :
>> Hi,
>>
>> spotted by Coverity (CID 701), a if (!spath) should be if (spath).
>>
>> Ciao, Marcus
>> ---
>>  programs/winedbg/source.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/programs/winedbg/source.c b/programs/winedbg/source.c
>> index 5519c57..1db7092 100644
>> --- a/programs/winedbg/source.c
>> +++ b/programs/winedbg/source.c
>> @@ -128,7 +128,7 @@ static BOOL     source_locate_file(const char* srcfile, char* path)
>>          while (!found)
>>          {
>>              spath = strchr(spath, '\\');
>> -            if (!spath) spath = strchr(spath, '/');
>> +            if (spath) spath = strchr(spath, '/');
>>              if (!spath) break;
>>              spath++;
>>              found = SearchPathA(dbg_curr_process->search_path, spath, NULL, MAX_PATH, path, NULL);
>>
> actually no
> the code intends to find the first occurence of / or \

In that case, the code is still incorrect.  Perhaps it should be:
-            if (!spath) spath = strchr(spath, '/');
+            if (!spath) spath = strchr(srcfile, '/');
instead?
--Juan



More information about the wine-devel mailing list