found should be true only if loc < n + 1

*pfound = (*ploc < n + 1);