Alexandre Julliard : winex11: Fix handling of property sizes for 64-bit platforms.

Alexandre Julliard julliard at winehq.org
Mon Apr 7 06:50:38 CDT 2008


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Apr  7 11:41:54 2008 +0200

winex11: Fix handling of property sizes for 64-bit platforms.

---

 dlls/winex11.drv/clipboard.c |    6 +++---
 dlls/winex11.drv/event.c     |    2 +-
 dlls/winex11.drv/graphics.c  |    2 +-
 dlls/winex11.drv/window.c    |    2 +-
 dlls/winex11.drv/winpos.c    |    2 +-
 dlls/winex11.drv/x11drv.h    |    7 +++++++
 dlls/winex11.drv/xdnd.c      |    2 +-
 7 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c
index 2996857..2404a71 100644
--- a/dlls/winex11.drv/clipboard.c
+++ b/dlls/winex11.drv/clipboard.c
@@ -1902,8 +1902,8 @@ static int X11DRV_CLIPBOARD_QueryAvailableData(LPCLIPBOARDINFO lpcbinfo)
         * The TARGETS property should have returned us a list of atoms
         * corresponding to each selection target format supported.
         */
-       if (atype == XA_ATOM || atype == x11drv_atom(TARGETS))
-           X11DRV_CLIPBOARD_InsertSelectionProperties(display, targetList, (cSelectionTargets * aformat / (8 * sizeof(Atom))));
+       if (aformat == 32 && (atype == XA_ATOM || atype == x11drv_atom(TARGETS)))
+           X11DRV_CLIPBOARD_InsertSelectionProperties(display, targetList, cSelectionTargets);
 
        /* Free the list of targets */
        wine_tsx11_lock();
@@ -2027,7 +2027,7 @@ static BOOL X11DRV_CLIPBOARD_ReadProperty(Window w, Atom prop,
             return FALSE;
         }
 
-        count = nitems * (aformat / 8);
+        count = get_property_size( aformat, nitems );
         if (!val) *data = HeapAlloc( GetProcessHeap(), 0, pos * sizeof(int) + count + 1 );
         else *data = HeapReAlloc( GetProcessHeap(), 0, val, pos * sizeof(int) + count + 1 );
 
diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c
index 8fd9b20..377e8f4 100644
--- a/dlls/winex11.drv/event.c
+++ b/dlls/winex11.drv/event.c
@@ -677,7 +677,7 @@ int get_window_wm_state( Display *display, struct x11drv_win_data *data )
                              sizeof(*state)/sizeof(CARD32), False, x11drv_atom(WM_STATE),
                              &type, &format, &count, &remaining, (unsigned char **)&state ))
     {
-        if (type == x11drv_atom(WM_STATE) && format && count >= sizeof(*state)/(format/8))
+        if (type == x11drv_atom(WM_STATE) && get_property_size( format, count ) >= sizeof(*state))
             ret = state->state;
         XFree( state );
     }
diff --git a/dlls/winex11.drv/graphics.c b/dlls/winex11.drv/graphics.c
index e75b594..af623ac 100644
--- a/dlls/winex11.drv/graphics.c
+++ b/dlls/winex11.drv/graphics.c
@@ -1394,7 +1394,7 @@ static unsigned char *get_icm_profile( unsigned long *size )
                         &type, &format, &count, &remaining, &profile );
     if (format && count)
     {
-        *size = count * (format / 8);
+        *size = get_property_size( format, count );
         if ((ret = HeapAlloc( GetProcessHeap(), 0, *size ))) memcpy( ret, profile, *size );
         XFree( profile );
     }
diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c
index e035041..6e4f468 100644
--- a/dlls/winex11.drv/window.c
+++ b/dlls/winex11.drv/window.c
@@ -866,7 +866,7 @@ static char *get_process_name(void)
  */
 static void set_initial_wm_hints( Display *display, struct x11drv_win_data *data )
 {
-    int i;
+    long i;
     Atom protocols[3];
     Atom dndVersion = 4;
     XClassHint *class_hints;
diff --git a/dlls/winex11.drv/winpos.c b/dlls/winex11.drv/winpos.c
index 25f7413..c63c868 100644
--- a/dlls/winex11.drv/winpos.c
+++ b/dlls/winex11.drv/winpos.c
@@ -618,7 +618,7 @@ static BOOL is_netwm_supported( Display *display, Atom atom )
         if (!XGetWindowProperty( display, DefaultRootWindow(display), x11drv_atom(_NET_SUPPORTED), 0,
                                  ~0UL, False, XA_ATOM, &type, &format, &count,
                                  &remaining, (unsigned char **)&net_supported ))
-            net_supported_count = count * (format / 8) / sizeof(Atom);
+            net_supported_count = get_property_size( format, count ) / sizeof(Atom);
         else
             net_supported_count = 0;
     }
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index ab5ff76..b47bdfa 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -520,6 +520,13 @@ static inline struct x11drv_thread_data *x11drv_thread_data(void)
 
 static inline Display *thread_display(void) { return x11drv_thread_data()->display; }
 
+static inline size_t get_property_size( int format, unsigned long count )
+{
+    /* format==32 means long, which can be 64 bits... */
+    if (format == 32) return count * sizeof(long);
+    return count * (format / 8);
+}
+
 extern Visual *visual;
 extern Window root_window;
 extern unsigned int screen_width;
diff --git a/dlls/winex11.drv/xdnd.c b/dlls/winex11.drv/xdnd.c
index 73674f5..1422578 100644
--- a/dlls/winex11.drv/xdnd.c
+++ b/dlls/winex11.drv/xdnd.c
@@ -286,7 +286,7 @@ static void X11DRV_XDND_ResolveProperty(Display *display, Window xwin, Time tm,
             AnyPropertyType, &acttype, &actfmt, &icount, &bytesret, &data);
         wine_tsx11_unlock();
 
-        entries += X11DRV_XDND_MapFormat(types[i], data, icount * (actfmt / 8));
+        entries += X11DRV_XDND_MapFormat(types[i], data, get_property_size( actfmt, icount ));
         wine_tsx11_lock();
         XFree(data);
         wine_tsx11_unlock();




More information about the wine-cvs mailing list