[cfe-commits] [PATCH] review request - strncmp checker

Ted Kremenek kremenek at apple.com
Mon Apr 25 14:36:50 PDT 2011


Great!  Looks good to me.

On Apr 25, 2011, at 10:19 AM, Lenny Maiorani wrote:

> On 04/22/2011 06:07 PM, Ted Kremenek wrote:
>> On Apr 15, 2011, at 1:27 PM, Lenny Maiorani wrote:
>> 
>>> Implements the strncmp() checker just like the strcmp() checker, but with bounds. Requires LLVM svn r129582.
>>> 
>>> Please review.
>>> 
>>> -Lenny
>> 
>> Hi Lenny,
>> 
>> This parts looks a bit suspect:
>> 
>> +  int result;
>> +  if (isBounded) {
>> +    // Get the max number of characters to compare.
>> +    const Expr *lenExpr = CE->getArg(2);
>> +    SVal lenVal = state->getSVal(lenExpr);
>> +    nonloc::ConcreteInt *CI = dyn_cast<nonloc::ConcreteInt>(&lenVal);
>> +    llvm::APSInt lenInt(CI->getValue());
>> 
>> There is no guarantee that lenVal will be a nonloc::ConcreteInt.  This means that the last line could be a null dereference.
>> 
>> Cheers,
>> Ted
> Hi Ted,
> 
> Ah yes. You are right. Attached is an updated patch which should fix that. Please review.
> 
> -Lenny
> 
> 
> <strncmp-checker-2.diff>




More information about the cfe-commits mailing list