Fix a potential undefined behaviour & improve some codes
- init grabSize - optimize WcharMbcsConvertor instance set - remove unused var in TreeView::searchLeafRecusivelyAndBuildTree() - missing nullpointer check in ScintillaEditView::init() Close #14844
This commit is contained in:
parent
83f0232d91
commit
9d09ee818a
|
@ -1054,7 +1054,7 @@ bool FileManager::backupCurrentBuffer()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
|
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
|
||||||
size_t grabSize;
|
size_t grabSize = 0;
|
||||||
for (size_t i = 0; i < lengthDoc; i += grabSize)
|
for (size_t i = 0; i < lengthDoc; i += grabSize)
|
||||||
{
|
{
|
||||||
grabSize = lengthDoc - i;
|
grabSize = lengthDoc - i;
|
||||||
|
@ -1209,14 +1209,14 @@ SavingStatus FileManager::saveBuffer(BufferID id, const TCHAR* filename, bool is
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
|
|
||||||
if (lengthDoc == 0)
|
if (lengthDoc == 0)
|
||||||
{
|
{
|
||||||
isWrittenSuccessful = UnicodeConvertor.writeFile(buf, 0);
|
isWrittenSuccessful = UnicodeConvertor.writeFile(buf, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
size_t grabSize;
|
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
|
||||||
|
size_t grabSize = 0;
|
||||||
for (size_t i = 0; i < lengthDoc; i += grabSize)
|
for (size_t i = 0; i < lengthDoc; i += grabSize)
|
||||||
{
|
{
|
||||||
grabSize = lengthDoc - i;
|
grabSize = lengthDoc - i;
|
||||||
|
|
|
@ -340,11 +340,14 @@ void ScintillaEditView::init(HINSTANCE hInst, HWND hPere)
|
||||||
{
|
{
|
||||||
auto defaultCharListLen = execute(SCI_GETWORDCHARS);
|
auto defaultCharListLen = execute(SCI_GETWORDCHARS);
|
||||||
char *defaultCharList = new char[defaultCharListLen + 1];
|
char *defaultCharList = new char[defaultCharListLen + 1];
|
||||||
|
if(defaultCharList)
|
||||||
|
{
|
||||||
execute(SCI_GETWORDCHARS, 0, reinterpret_cast<LPARAM>(defaultCharList));
|
execute(SCI_GETWORDCHARS, 0, reinterpret_cast<LPARAM>(defaultCharList));
|
||||||
defaultCharList[defaultCharListLen] = '\0';
|
defaultCharList[defaultCharListLen] = '\0';
|
||||||
_defaultCharList = defaultCharList;
|
_defaultCharList = defaultCharList;
|
||||||
delete[] defaultCharList;
|
delete[] defaultCharList;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//Get the startup document and make a buffer for it so it can be accessed like a file
|
//Get the startup document and make a buffer for it so it can be accessed like a file
|
||||||
attachDefaultDoc();
|
attachDefaultDoc();
|
||||||
}
|
}
|
||||||
|
|
|
@ -660,14 +660,12 @@ bool TreeView::searchLeafRecusivelyAndBuildTree(HTREEITEM tree2Build, const gene
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t i = 0;
|
|
||||||
bool isOk = true;
|
bool isOk = true;
|
||||||
for (HTREEITEM hItem = getChildFrom(tree2Search); hItem != NULL; hItem = getNextSibling(hItem))
|
for (HTREEITEM hItem = getChildFrom(tree2Search); hItem != NULL; hItem = getNextSibling(hItem))
|
||||||
{
|
{
|
||||||
isOk = searchLeafRecusivelyAndBuildTree(tree2Build, text2Search, index2Search, hItem);
|
isOk = searchLeafRecusivelyAndBuildTree(tree2Build, text2Search, index2Search, hItem);
|
||||||
if (!isOk)
|
if (!isOk)
|
||||||
break;
|
break;
|
||||||
++i;
|
|
||||||
}
|
}
|
||||||
return isOk;
|
return isOk;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue