Partially fix type of function pointer.

Found using UBSan.
Full fix would require adding visibility attribute to CUser,
CIRCNetwork, CModule, CModuleEntry, CModInfo *and* make sure these
attributes are visible to enough code.
The second statement is more difficult to fulfill, because forward
declaration of CUser is not enough, because the attribute is on class
definition. So Modules.h would need to include many other includes.

Probably it should be changed at some point.

See http://stackoverflow.com/questions/27976687/clangs-ubsan-function-pointer-is-this-illegal
This commit is contained in:
Alexey Sokolov
2016-12-26 19:54:52 +00:00
parent 1b5bd128cc
commit b4b085dc2d

View File

@@ -1917,7 +1917,7 @@ ModHandle CModules::OpenModule(const CString& sModule, const CString& sModPath,
return nullptr;
}
CModuleEntry* (*fpZNCModuleEntry)() = nullptr;
const CModuleEntry* (*fpZNCModuleEntry)() = nullptr;
// man dlsym(3) explains this
*reinterpret_cast<void**>(&fpZNCModuleEntry) = dlsym(p, "ZNCModuleEntry");
if (!fpZNCModuleEntry) {