From b4b085dc2db69b58f2ad3bb4271ff3789e8301b5 Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Mon, 26 Dec 2016 19:54:52 +0000 Subject: [PATCH] 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 --- src/Modules.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Modules.cpp b/src/Modules.cpp index 7e7dd8bd..cfec1139 100644 --- a/src/Modules.cpp +++ b/src/Modules.cpp @@ -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(&fpZNCModuleEntry) = dlsym(p, "ZNCModuleEntry"); if (!fpZNCModuleEntry) {