[BUGFIX] Added protection against invalid start/end markers in wchar2char and char2wchar. This is needed for find in files where the result is found in a line containing the null character (binary files). This caused an Access violation exception because the markers were past the EOL in this case (char2wchar), and then they were used in wchar2char.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@475 f5eea248-9336-0410-98b8-ebc06183d4e3
remotes/x64
Yuval 16 years ago
parent b20baeac19
commit a5ddc3e7b3

@ -286,9 +286,14 @@ const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT c
_wideCharAllocLen = len; _wideCharAllocLen = len;
_wideCharStr = new wchar_t[_wideCharAllocLen]; _wideCharStr = new wchar_t[_wideCharAllocLen];
} }
MultiByteToWideChar(codepage, 0, mbcs2Convert, -1, _wideCharStr, len); len = MultiByteToWideChar(codepage, 0, mbcs2Convert, -1, _wideCharStr, len);
*mstart = MultiByteToWideChar(codepage, 0, mbcs2Convert, *mstart, _wideCharStr, 0); *mstart = MultiByteToWideChar(codepage, 0, mbcs2Convert, *mstart, _wideCharStr, 0);
*mend = MultiByteToWideChar(codepage, 0, mbcs2Convert, *mend, _wideCharStr, 0); *mend = MultiByteToWideChar(codepage, 0, mbcs2Convert, *mend, _wideCharStr, 0);
if (*mstart >= len || *mend >= len)
{
*mstart = 0;
*mend = 0;
}
} }
else else
{ {
@ -341,9 +346,14 @@ const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, UI
_multiByteAllocLen = len; _multiByteAllocLen = len;
_multiByteStr = new char[_multiByteAllocLen]; _multiByteStr = new char[_multiByteAllocLen];
} }
WideCharToMultiByte(codepage, 0, wcharStr2Convert, -1, _multiByteStr, len, NULL, NULL); len = WideCharToMultiByte(codepage, 0, wcharStr2Convert, -1, _multiByteStr, len, NULL, NULL); // not needed?
*mstart = WideCharToMultiByte(codepage, 0, wcharStr2Convert, *mstart, _multiByteStr, 0, NULL, NULL); *mstart = WideCharToMultiByte(codepage, 0, wcharStr2Convert, *mstart, _multiByteStr, 0, NULL, NULL);
*mend = WideCharToMultiByte(codepage, 0, wcharStr2Convert, *mend, _multiByteStr, 0, NULL, NULL); *mend = WideCharToMultiByte(codepage, 0, wcharStr2Convert, *mend, _multiByteStr, 0, NULL, NULL);
if (*mstart >= len || *mend >= len)
{
*mstart = 0;
*mend = 0;
}
} }
else else
_multiByteStr[0] = 0; _multiByteStr[0] = 0;

Loading…
Cancel
Save