mirror of
https://github.com/SFML/SFML.git
synced 2025-01-18 15:25:12 +08:00
Fix segfault if XOpenIM fails
If `XOpenIM` fails we will store a `nullptr` into `sharedXIM`. When the shared `XIM` is destroyed we call the deleter `XCloseIM` on the `nullptr` which segfaults. Fix this by adding a new `closeIM` helper function which checks for null first.
This commit is contained in:
parent
ad70442246
commit
e1bb69b3b5
@ -104,7 +104,12 @@ std::shared_ptr<_XIM> openXim()
|
||||
XSetLocaleModifiers("");
|
||||
|
||||
// Create the input context
|
||||
sharedXIM.reset(XOpenIM(UnixDisplayImpl::weakSharedDisplay.lock().get(), nullptr, nullptr, nullptr), XCloseIM);
|
||||
const auto closeIM = [](XIM im)
|
||||
{
|
||||
if (im)
|
||||
XCloseIM(im);
|
||||
};
|
||||
sharedXIM.reset(XOpenIM(UnixDisplayImpl::weakSharedDisplay.lock().get(), nullptr, nullptr, nullptr), closeIM);
|
||||
xim = sharedXIM;
|
||||
|
||||
// Restore the previous locale
|
||||
|
Loading…
Reference in New Issue
Block a user