[cfe-dev] ConvertArgumentsForCall may segfault when called function has default parameters

Keno Fischer kfischer at college.harvard.edu
Thu Aug 14 13:23:30 PDT 2014


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. One possible fix is to
move the call to Call->getLocStart() before the adjustment of the
number of function arguments. Does anybody see something better? It
seems to me that this shouldn't segfault even on an invalid location,
since getLocStart even explicitly checks for the 0 argument case.


More information about the cfe-dev mailing list