Thomas Faller : winex11.drv: Fix use of uninitialized memory.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Oct 1 10:57:01 CDT 2015


Module: wine
Branch: master
Commit: 587733855b55725d637e044ad9ac0232a79de919
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=587733855b55725d637e044ad9ac0232a79de919

Author: Thomas Faller <tfaller1 at gmx.de>
Date:   Thu Sep 24 23:44:17 2015 +0200

winex11.drv: Fix use of uninitialized memory.

---

 dlls/winex11.drv/clipboard.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c
index 6c6b3b9..842ebfe 100644
--- a/dlls/winex11.drv/clipboard.c
+++ b/dlls/winex11.drv/clipboard.c
@@ -367,8 +367,19 @@ static void intern_atoms(void)
     i = 0;
     LIST_FOR_EACH_ENTRY( format, &format_list, WINE_CLIPFORMAT, entry )
         if (!format->drvData) {
-            GetClipboardFormatNameW( format->wFormatID, buffer, 256 );
-            len = WideCharToMultiByte(CP_UNIXCP, 0, buffer, -1, NULL, 0, NULL, NULL);
+            if (GetClipboardFormatNameW(format->wFormatID, buffer, 256) > 0)
+            {
+                /* use defined format name */
+                len = WideCharToMultiByte(CP_UNIXCP, 0, buffer, -1, NULL, 0, NULL, NULL);
+            }
+            else
+            {
+                /* create a name in the same way as ntdll/atom.c:integral_atom_name
+                 * which is normally used by GetClipboardFormatNameW
+                 */
+                static const WCHAR fmt[] = {'#','%','u',0};
+                len = sprintfW(buffer, fmt, format->wFormatID) + 1;
+            }
             names[i] = HeapAlloc(GetProcessHeap(), 0, len);
             WideCharToMultiByte(CP_UNIXCP, 0, buffer, -1, names[i++], len, NULL, NULL);
         }




More information about the wine-cvs mailing list