codeql icon indicating copy to clipboard operation
codeql copied to clipboard

General issue: How to resolve function of FunctionPointerCall?

Open pangodev91 opened this issue 4 weeks ago • 0 comments

Description of the issue

I want to resolve calls made with pointer variables, such as:

struct foo_struct {
	void (*foo)(void);
};

static void foo_func(void)
{
	printf("hello from foo_func\n");
}

static struct foo_struct bar_ops = {
	.foo = foo_func,
};

int main(void)
{
	// pointer call to foo_func
	struct foo_struct *ops_ptr = &bar_ops;
	ops_ptr->foo();

	// another pointer call to foo_func
	void (*ptr_call)(void);
	ptr_call = foo_func;
	ptr_call();

	return 0;
}

Why can't resolveCall from import semmle.code.cpp.ir.dataflow.ResolveCall resolve it? Is there a solution available for this? Thanks in advance.

pangodev91 avatar Dec 12 '25 23:12 pangodev91