From a0383275211ce4031d44ace7a76768ed28e61f08 Mon Sep 17 00:00:00 2001 From: Ilya Zhuravlev Date: Wed, 17 Jan 2018 23:03:11 -0500 Subject: [PATCH] SDLCursorManager: fix possibly invalid read when no cursor present On android we have no cursor so I moved the check closer to usage --- components/sdlutil/sdlcursormanager.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/components/sdlutil/sdlcursormanager.cpp b/components/sdlutil/sdlcursormanager.cpp index c32891e37..65aa2106f 100644 --- a/components/sdlutil/sdlcursormanager.cpp +++ b/components/sdlutil/sdlcursormanager.cpp @@ -203,19 +203,14 @@ namespace SDLUtil void SDLCursorManager::cursorChanged(const std::string& name) { mCurrentCursor = name; - - CursorMap::const_iterator curs_iter = mCursorMap.find(name); - - if(curs_iter != mCursorMap.end()) - { - //we have this cursor - _setGUICursor(name); - } + _setGUICursor(name); } void SDLCursorManager::_setGUICursor(const std::string &name) { - SDL_SetCursor(mCursorMap.find(name)->second); + auto it = mCursorMap.find(name); + if (it != mCursorMap.end()) + SDL_SetCursor(it->second); } void SDLCursorManager::createCursor(const std::string& name, int rotDegrees, osg::Image* image, Uint8 hotspot_x, Uint8 hotspot_y)