A method comprising: compiling a source code file, the source code file comprising: one or more classes, wherein each of the classes has a virtual table containing at least one virtual function pointer that is pointing to a virtual function, and a virtual function invocation site associated with a virtual function, wherein the compiling comprises: associating a security check function with the virtual function invocation site such that the associated security check function is executed prior to an invocation of the virtual function; generating a Class Hierarchy Hash Table, CHHT, wherein the generating comprises: hashing, for each class, an address of the virtual table with each virtual function pointer contained in the virtual table to produce a hash result for each of the virtual function pointers and associating each of the hash results with an indicator, and populating the CHHT with the hash results and their associated indicators; wherein the security check function is configured to determine whether a virtual function pointer of a virtual function associated with the security check function is valid by looking up an indicator in the CHHT according to a hash result of the virtual function pointer of the virtual function and an address of a virtual table containing the virtual function pointer. compiling a source code file, the source code file comprising: one or more classes, wherein each of the classes has a virtual table containing at least one virtual function pointer that is pointing to a virtual function, and a virtual function invocation site associated with a virtual function, wherein the compiling comprises: associating a security check function with the virtual function invocation site such that the associated security check function is executed prior to an invocation of the virtual function; generating a Class Hierarchy Hash Table, CHHT, wherein the generating comprises: hashing, for each class, an address of the virtual table with each virtual function pointer contained in the virtual table to produce a hash result for each of the virtual function pointers and associating each of the hash results with an indicator, and populating the CHHT with the hash results and their associated indicators; wherein the security check function is configured to determine whether a virtual function pointer of a virtual function associated with the security check function is valid by looking up an indicator in the CHHT according to a hash result of the virtual function pointer of the virtual function and an address of a virtual table containing the virtual function pointer. associating a security check function with the virtual function invocation site such that the associated security check function is executed prior to an invocation of the virtual function; generating a Class Hierarchy Hash Table, CHHT, wherein the generating comprises: hashing, for each class, an address of the virtual table with each virtual function pointer contained in the virtual table to produce a hash result for each of the virtual function pointers and associating each of the hash results with an indicator, and populating the CHHT with the hash results and their associated indicators; wherein the security check function is configured to determine whether a virtual function pointer of a virtual function associated with the security check function is valid by looking up an indicator in the CHHT according to a hash result of the virtual function pointer of the virtual function and an address of a virtual table containing the virtual function pointer.