Fixed NULL Pointer Dereference

A weakness has been found by using PVS-Studio analyzer.

Analyzer warnings:

* V595 The 'pScint' pointer was utilized before it was verified against
nullptr. Check lines: 347, 353. scintillaeditview.cpp 347

* V713 The pointer _langList[i] was utilized in the logical expression
before it was verified against nullptr in the same logical expression.
parameters.h 1286

closes #3400
This commit is contained in:
Svyatoslav 2017-06-14 12:33:35 +03:00 committed by Don HO
parent 694fd80fa5
commit 6d542a4041
2 changed files with 2 additions and 2 deletions

View File

@ -1283,7 +1283,7 @@ public:
{ {
for (int i = 0 ; i < _nbLang ; ++i) for (int i = 0 ; i < _nbLang ; ++i)
{ {
if ((_langList[i]->_langID == langID) || (!_langList[i])) if ( _langList[i] && _langList[i]->_langID == langID )
return _langList[i]; return _langList[i];
} }
return nullptr; return nullptr;

View File

@ -343,7 +343,7 @@ LRESULT CALLBACK ScintillaEditView::scintillaStatic_Proc(HWND hwnd, UINT Message
bool isSynpnatic = std::string(synapticsHack) == "SynTrackCursorWindowClass"; bool isSynpnatic = std::string(synapticsHack) == "SynTrackCursorWindowClass";
bool makeTouchPadCompetible = ((NppParameters::getInstance())->getSVP())._disableAdvancedScrolling; bool makeTouchPadCompetible = ((NppParameters::getInstance())->getSVP())._disableAdvancedScrolling;
if (isSynpnatic || makeTouchPadCompetible) if (pScint && (isSynpnatic || makeTouchPadCompetible))
return (pScint->scintillaNew_Proc(hwnd, Message, wParam, lParam)); return (pScint->scintillaNew_Proc(hwnd, Message, wParam, lParam));
ScintillaEditView *pScintillaOnMouse = (ScintillaEditView *)(::GetWindowLongPtr(hwndOnMouse, GWLP_USERDATA)); ScintillaEditView *pScintillaOnMouse = (ScintillaEditView *)(::GetWindowLongPtr(hwndOnMouse, GWLP_USERDATA));