[LPK] Added more error handling code (#622).
authorBaruch Rutman <peterooch@gmail.com>
Mon, 18 Jun 2018 14:54:15 +0000 (17:54 +0300)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Thu, 26 Jul 2018 22:47:28 +0000 (00:47 +0200)
- Added a codepath if both glyphs and reordered_str arrays are NULL.
- Move variables back to the beginning of function.

CORE-14732

dll/win32/lpk/lpk.c

index 85e2e8f..03ed326 100644 (file)
@@ -63,6 +63,11 @@ LpkExtTextOut(
     const INT *lpDx,
     INT unknown)
 {
+    LPWORD glyphs = NULL;
+    LPWSTR reordered_str = NULL;
+    INT cGlyphs;
+    BOOL bResult;
+
     UNREFERENCED_PARAMETER(unknown);
 
     if (!(fuOptions & ETO_IGNORELANGUAGE))
@@ -78,10 +83,7 @@ LpkExtTextOut(
     /* Check if the string requires complex script processing and not a "glyph indices" array */
     if (ScriptIsComplex(lpString, uCount, SIC_COMPLEX) == S_OK && !(fuOptions & ETO_GLYPH_INDEX))
     {
-        LPWORD glyphs = NULL;
-        LPWSTR reordered_str = HeapAlloc(GetProcessHeap(), 0, uCount * sizeof(WCHAR));
-        INT cGlyphs;
-        BOOL bResult;
+        reordered_str = HeapAlloc(GetProcessHeap(), 0, uCount * sizeof(WCHAR));
 
         BIDI_Reorder(hdc, lpString, uCount, GCP_REORDER,
                      (fuOptions & ETO_RTLREADING) ? WINE_GCPW_FORCE_RTL : WINE_GCPW_FORCE_LTR,
@@ -90,13 +92,17 @@ LpkExtTextOut(
         if (glyphs)
         {
             fuOptions |= ETO_GLYPH_INDEX;
+            uCount = cGlyphs;
+        }
 
-            if (uCount != cGlyphs)
-                uCount = cGlyphs;
+        if (glyphs || reordered_str)
+        {
+            bResult = ExtTextOutW(hdc, x, y, fuOptions, lprc,
+                                  glyphs ? (LPWSTR)glyphs : reordered_str, uCount, lpDx);
         }
 
-        bResult = ExtTextOutW(hdc, x, y, fuOptions, lprc,
-                              glyphs ? (LPWSTR)glyphs : reordered_str, uCount, lpDx);
+        else
+            bResult = ExtTextOutW(hdc, x, y, fuOptions, lprc, lpString, uCount, lpDx);
 
         HeapFree(GetProcessHeap(), 0, glyphs);
         HeapFree(GetProcessHeap(), 0, reordered_str);