Page MenuHomePhabricator

Make sure CallExpr::getLocStart doesn't segfault
ClosedPublic

Authored by loladiro on Aug 14 2014, 4:14 PM.

Details

Summary

When the CallExpr passed to Sema::ConvertArgumentsForCall has all default parameters, and the number of actual arguments passed is zero, this function will segfault in the call to Call->getLocStart() if the Callee has an invalid getLocStart(), the reason being that since ConvertArgumentsForCall has set the correct number of arguments, but has not filled them in yet, getLocStart() will try to access the first (not yet existent) argument and thus segfaults.

This fixes that by making getLocStart return an invalid source location if the queried argument is NULL rather than segfaulting.

Diff Detail

Repository
rL LLVM

Event Timeline

loladiro updated this revision to Diff 12528.Aug 14 2014, 4:14 PM
loladiro retitled this revision from to Make sure CallExpr::getLocStart doesn't segfault.
loladiro updated this object.
loladiro edited the test plan for this revision. (Show Details)
loladiro added a reviewer: rnk.
loladiro set the repository for this revision to rL LLVM.
loladiro added a subscriber: Unknown Object (MLST).
rnk accepted this revision.Aug 14 2014, 4:49 PM
rnk edited edge metadata.

lgtm

lib/AST/Expr.cpp
1255 ↗(On Diff #12528)

Clang and LLVM typically rely on implicit truth for null tests, so "&& getArg(0)" is probably enough.

This revision is now accepted and ready to land.Aug 14 2014, 4:49 PM
loladiro added inline comments.Aug 14 2014, 6:40 PM
lib/AST/Expr.cpp
1255 ↗(On Diff #12528)

Ok, will change and commit.

loladiro closed this revision.Aug 14 2014, 6:48 PM
loladiro updated this revision to Diff 12538.

Closed by commit rL215686 (authored by kfischer).