mirror of
https://github.com/reactos/reactos.git
synced 2024-07-06 12:45:16 +00:00
[INPUT]
- Use _wcsdup instead internal DuplicateString - Check of the returned value of the wcsstr function is added svn path=/trunk/; revision=72301
This commit is contained in:
parent
9b71c6be30
commit
c5ba8fbb12
|
@ -75,23 +75,6 @@ INT_PTR CALLBACK
|
||||||
ChangeKeySeqDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
ChangeKeySeqDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
|
|
||||||
static inline WCHAR*
|
|
||||||
DuplicateString(const WCHAR *pszString)
|
|
||||||
{
|
|
||||||
WCHAR *pszDuplicate;
|
|
||||||
size_t size;
|
|
||||||
|
|
||||||
size = (wcslen(pszString) + 1) * sizeof(WCHAR);
|
|
||||||
|
|
||||||
pszDuplicate = (WCHAR*) malloc(size);
|
|
||||||
if (pszDuplicate != NULL)
|
|
||||||
{
|
|
||||||
StringCbCopyW(pszDuplicate, size, pszString);
|
|
||||||
}
|
|
||||||
|
|
||||||
return pszDuplicate;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline DWORD
|
static inline DWORD
|
||||||
DWORDfromString(const WCHAR *pszString)
|
DWORDfromString(const WCHAR *pszString)
|
||||||
{
|
{
|
||||||
|
|
|
@ -318,7 +318,7 @@ InputList_Add(LOCALE_LIST_NODE *pLocale, LAYOUT_LIST_NODE *pLayout)
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
{
|
{
|
||||||
szIndicator[len - 1] = 0;
|
szIndicator[len - 1] = 0;
|
||||||
pInput->pszIndicator = DuplicateString(szIndicator);
|
pInput->pszIndicator = _wcsdup(szIndicator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,7 +447,7 @@ InputList_Create(VOID)
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
{
|
{
|
||||||
szIndicator[len - 1] = 0;
|
szIndicator[len - 1] = 0;
|
||||||
pInput->pszIndicator = DuplicateString(szIndicator);
|
pInput->pszIndicator = _wcsdup(szIndicator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ LayoutList_AppendNode(DWORD dwId, DWORD dwSpecialId, const WCHAR *pszName)
|
||||||
|
|
||||||
ZeroMemory(pNew, sizeof(LAYOUT_LIST_NODE));
|
ZeroMemory(pNew, sizeof(LAYOUT_LIST_NODE));
|
||||||
|
|
||||||
pNew->pszName = DuplicateString(pszName);
|
pNew->pszName = _wcsdup(pszName);
|
||||||
if (pNew->pszName == NULL)
|
if (pNew->pszName == NULL)
|
||||||
{
|
{
|
||||||
free(pNew);
|
free(pNew);
|
||||||
|
@ -153,10 +153,8 @@ LayoutList_Create(VOID)
|
||||||
(LPBYTE)szBuffer, &dwSize) == ERROR_SUCCESS &&
|
(LPBYTE)szBuffer, &dwSize) == ERROR_SUCCESS &&
|
||||||
szBuffer[0] == L'@')
|
szBuffer[0] == L'@')
|
||||||
{
|
{
|
||||||
WCHAR szPath[MAX_PATH];
|
|
||||||
WCHAR *pBuffer;
|
WCHAR *pBuffer;
|
||||||
WCHAR *pIndex;
|
WCHAR *pIndex;
|
||||||
INT iIndex;
|
|
||||||
|
|
||||||
/* Move to the position after the character "@" */
|
/* Move to the position after the character "@" */
|
||||||
pBuffer = szBuffer + 1;
|
pBuffer = szBuffer + 1;
|
||||||
|
@ -164,27 +162,37 @@ LayoutList_Create(VOID)
|
||||||
/* Get a pointer to the beginning ",-" */
|
/* Get a pointer to the beginning ",-" */
|
||||||
pIndex = wcsstr(pBuffer, L",-");
|
pIndex = wcsstr(pBuffer, L",-");
|
||||||
|
|
||||||
/* Convert the number in the string after the ",-" */
|
if (pIndex != NULL)
|
||||||
iIndex = _wtoi(pIndex + 2);
|
|
||||||
|
|
||||||
pIndex[0] = 0;
|
|
||||||
|
|
||||||
if (ExpandEnvironmentStringsW(pBuffer, szPath, ARRAYSIZE(szPath)) != 0)
|
|
||||||
{
|
{
|
||||||
HANDLE hHandle;
|
WCHAR szPath[MAX_PATH];
|
||||||
|
INT iIndex;
|
||||||
|
|
||||||
hHandle = LoadLibraryW(szPath);
|
/* Convert the number in the string after the ",-" */
|
||||||
if (hHandle != NULL)
|
iIndex = _wtoi(pIndex + 2);
|
||||||
|
|
||||||
|
pIndex[0] = 0;
|
||||||
|
|
||||||
|
if (ExpandEnvironmentStringsW(pBuffer, szPath, ARRAYSIZE(szPath)) != 0)
|
||||||
{
|
{
|
||||||
INT iLength = LoadStringW(hHandle, iIndex, szBuffer, ARRAYSIZE(szBuffer));
|
HANDLE hHandle;
|
||||||
|
|
||||||
FreeLibrary(hHandle);
|
hHandle = LoadLibraryW(szPath);
|
||||||
|
if (hHandle != NULL)
|
||||||
if (iLength != 0)
|
|
||||||
{
|
{
|
||||||
DWORD dwLayoutId = DWORDfromString(szLayoutId);
|
INT iLength = LoadStringW(hHandle, iIndex, szBuffer, ARRAYSIZE(szBuffer));
|
||||||
|
|
||||||
LayoutList_AppendNode(dwLayoutId, dwSpecialId, szBuffer);
|
FreeLibrary(hHandle);
|
||||||
|
|
||||||
|
if (iLength != 0)
|
||||||
|
{
|
||||||
|
DWORD dwLayoutId = DWORDfromString(szLayoutId);
|
||||||
|
|
||||||
|
LayoutList_AppendNode(dwLayoutId, dwSpecialId, szBuffer);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
goto NotTranslated;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,7 +28,7 @@ LocaleList_Append(DWORD dwId, const WCHAR *pszName)
|
||||||
|
|
||||||
ZeroMemory(pNew, sizeof(LOCALE_LIST_NODE));
|
ZeroMemory(pNew, sizeof(LOCALE_LIST_NODE));
|
||||||
|
|
||||||
pNew->pszName = DuplicateString(pszName);
|
pNew->pszName = _wcsdup(pszName);
|
||||||
if (pNew->pszName == NULL)
|
if (pNew->pszName == NULL)
|
||||||
{
|
{
|
||||||
free(pNew);
|
free(pNew);
|
||||||
|
|
Loading…
Reference in a new issue