diff options
| author | Neil <nyamatongwe@gmail.com> | 2019-12-13 14:55:15 +1100 | 
|---|---|---|
| committer | Neil <nyamatongwe@gmail.com> | 2019-12-13 14:55:15 +1100 | 
| commit | eab0c872c43486e670cb0157f83910982e3ad10b (patch) | |
| tree | 1a58ba1c9c1bcfa7d7c74598ca6e443bd2f2959e /qt/ScintillaEditBase/PlatQt.cpp | |
| parent | 952cd885fb6055c1e133ca53e3348d0e0b9d6cab (diff) | |
| download | scintilla-mirror-eab0c872c43486e670cb0157f83910982e3ad10b.tar.gz | |
Use safe mechanism for converting between function pointers and void*.
Diffstat (limited to 'qt/ScintillaEditBase/PlatQt.cpp')
| -rw-r--r-- | qt/ScintillaEditBase/PlatQt.cpp | 16 | 
1 files changed, 8 insertions, 8 deletions
diff --git a/qt/ScintillaEditBase/PlatQt.cpp b/qt/ScintillaEditBase/PlatQt.cpp index 515052a48..3d285a337 100644 --- a/qt/ScintillaEditBase/PlatQt.cpp +++ b/qt/ScintillaEditBase/PlatQt.cpp @@ -1119,17 +1119,17 @@ public:  	}  	Function FindFunction(const char *name) override {  		if (lib) { -			// C++ standard doesn't like casts between function pointers and void pointers so use a union -			union { +			// Use memcpy as it doesn't invoke undefined or conditionally defined behaviour.  #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) -				QFunctionPointer fp; +			QFunctionPointer fp {};  #else -				void *fp; +			void *fp = nullptr;  #endif -				Function f; -			} fnConv; -			fnConv.fp = lib->resolve(name); -			return fnConv.f; +			fp = lib->resolve(name); +			Function f = nullptr; +			static_assert(sizeof(f) == sizeof(fp)); +			memcpy(&f, &fp, sizeof(f)); +			return f;  		}  		return nullptr;  	}  | 
