cpg icon indicating copy to clipboard operation
cpg copied to clipboard

Add support for function pointer factories

Open Masrepus opened this issue 5 years ago • 1 comments

While trying to make the dummy creation behavior more consistent, I stumbled over the following situation:

void target(int param) {}

void (*getTarget(int))(int) {
  return ⌖
}

void main() {
  void (*fptr)(int) = getTarget(0);
}

The function pointer resolving process now correctly supports these situations, as previously it would have thought that getTarget is the target of fptr. Anyway, this only works in theory, as the broader issue currently is that we can't find out that getTarget returns something of type void (*)(int) but rather void* is used. Thus, we need to improve the type parser to support the weird syntax of function pointer "factories" as I would name these methods.

Masrepus avatar Aug 14 '20 14:08 Masrepus

Good catch :) A function returning a function pointer is... interesting...

oxisto avatar Aug 14 '20 19:08 oxisto