Author: dchapyshev
Date: Thu Aug 18 10:31:42 2016
New Revision: 72301

URL: http://svn.reactos.org/svn/reactos?rev=72301&view=rev
Log:
[INPUT]
- Use _wcsdup instead internal DuplicateString
- Check of the returned value of the wcsstr function is added

Modified:
    trunk/reactos/dll/cpl/input/input.h
    trunk/reactos/dll/cpl/input/input_list.c
    trunk/reactos/dll/cpl/input/layout_list.c
    trunk/reactos/dll/cpl/input/locale_list.c

Modified: trunk/reactos/dll/cpl/input/input.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input/input.h?rev=72301&r1=72300&r2=72301&view=diff
==============================================================================
--- trunk/reactos/dll/cpl/input/input.h [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input/input.h [iso-8859-1] Thu Aug 18 10:31:42 2016
@@ -75,23 +75,6 @@
 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
 DWORDfromString(const WCHAR *pszString)
 {

Modified: trunk/reactos/dll/cpl/input/input_list.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input/input_list.c?rev=72301&r1=72300&r2=72301&view=diff
==============================================================================
--- trunk/reactos/dll/cpl/input/input_list.c    [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input/input_list.c    [iso-8859-1] Thu Aug 18 
10:31:42 2016
@@ -318,7 +318,7 @@
         if (len > 0)
         {
             szIndicator[len - 1] = 0;
-            pInput->pszIndicator = DuplicateString(szIndicator);
+            pInput->pszIndicator = _wcsdup(szIndicator);
         }
     }
 
@@ -447,7 +447,7 @@
                         if (len > 0)
                         {
                             szIndicator[len - 1] = 0;
-                            pInput->pszIndicator = 
DuplicateString(szIndicator);
+                            pInput->pszIndicator = _wcsdup(szIndicator);
                         }
                     }
                 }

Modified: trunk/reactos/dll/cpl/input/layout_list.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input/layout_list.c?rev=72301&r1=72300&r2=72301&view=diff
==============================================================================
--- trunk/reactos/dll/cpl/input/layout_list.c   [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input/layout_list.c   [iso-8859-1] Thu Aug 18 
10:31:42 2016
@@ -28,7 +28,7 @@
 
     ZeroMemory(pNew, sizeof(LAYOUT_LIST_NODE));
 
-    pNew->pszName = DuplicateString(pszName);
+    pNew->pszName = _wcsdup(pszName);
     if (pNew->pszName == NULL)
     {
         free(pNew);
@@ -153,10 +153,8 @@
                                          (LPBYTE)szBuffer, &dwSize) == 
ERROR_SUCCESS &&
                         szBuffer[0] == L'@')
                     {
-                        WCHAR szPath[MAX_PATH];
                         WCHAR *pBuffer;
                         WCHAR *pIndex;
-                        INT iIndex;
 
                         /* Move to the position after the character "@" */
                         pBuffer = szBuffer + 1;
@@ -164,27 +162,37 @@
                         /* Get a pointer to the beginning ",-" */
                         pIndex = wcsstr(pBuffer, L",-");
 
-                        /* Convert the number in the string after the ",-" */
-                        iIndex = _wtoi(pIndex + 2);
-
-                        pIndex[0] = 0;
-
-                        if (ExpandEnvironmentStringsW(pBuffer, szPath, 
ARRAYSIZE(szPath)) != 0)
+                        if (pIndex != NULL)
                         {
-                            HANDLE hHandle;
-
-                            hHandle = LoadLibraryW(szPath);
-                            if (hHandle != NULL)
+                            WCHAR szPath[MAX_PATH];
+                            INT iIndex;
+
+                            /* Convert the number in the string after the ",-" 
*/
+                            iIndex = _wtoi(pIndex + 2);
+
+                            pIndex[0] = 0;
+
+                            if (ExpandEnvironmentStringsW(pBuffer, szPath, 
ARRAYSIZE(szPath)) != 0)
                             {
-                                INT iLength = LoadStringW(hHandle, iIndex, 
szBuffer, ARRAYSIZE(szBuffer));
-
-                                FreeLibrary(hHandle);
-
-                                if (iLength != 0)
+                                HANDLE hHandle;
+
+                                hHandle = LoadLibraryW(szPath);
+                                if (hHandle != NULL)
                                 {
-                                    DWORD dwLayoutId = 
DWORDfromString(szLayoutId);
-
-                                    LayoutList_AppendNode(dwLayoutId, 
dwSpecialId, szBuffer);
+                                    INT iLength = LoadStringW(hHandle, iIndex, 
szBuffer, ARRAYSIZE(szBuffer));
+
+                                    FreeLibrary(hHandle);
+
+                                    if (iLength != 0)
+                                    {
+                                        DWORD dwLayoutId = 
DWORDfromString(szLayoutId);
+
+                                        LayoutList_AppendNode(dwLayoutId, 
dwSpecialId, szBuffer);
+                                    }
+                                    else
+                                    {
+                                        goto NotTranslated;
+                                    }
                                 }
                                 else
                                 {

Modified: trunk/reactos/dll/cpl/input/locale_list.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/input/locale_list.c?rev=72301&r1=72300&r2=72301&view=diff
==============================================================================
--- trunk/reactos/dll/cpl/input/locale_list.c   [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/input/locale_list.c   [iso-8859-1] Thu Aug 18 
10:31:42 2016
@@ -28,7 +28,7 @@
 
     ZeroMemory(pNew, sizeof(LOCALE_LIST_NODE));
 
-    pNew->pszName = DuplicateString(pszName);
+    pNew->pszName = _wcsdup(pszName);
     if (pNew->pszName == NULL)
     {
         free(pNew);


Reply via email to