[Xfce4-commits] <xfdesktop:master> Fix strict aliasing issue

Eric Koegel noreply at xfce.org
Mon Feb 10 14:08:01 CET 2014


Updating branch refs/heads/master
         to 369fe226968f678faf255805f5285665f20e03af (commit)
       from e339463f95c70578aae33f339ac54433f51cc5ae (commit)

commit 369fe226968f678faf255805f5285665f20e03af
Author: Eric Koegel <eric.koegel at gmail.com>
Date:   Mon Feb 10 16:06:21 2014 +0300

    Fix strict aliasing issue

 src/xfdesktop-icon-view.c |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/xfdesktop-icon-view.c b/src/xfdesktop-icon-view.c
index 8f64603..a7f1faa 100644
--- a/src/xfdesktop-icon-view.c
+++ b/src/xfdesktop-icon-view.c
@@ -3405,7 +3405,7 @@ xfdesktop_get_workarea_single(XfdesktopIconView *icon_view,
     Window root;
     Atom property, actual_type = None;
     gint actual_format = 0, first_id;
-    gulong nitems = 0, bytes_after = 0, offset = 0;
+    gulong nitems = 0, bytes_after = 0, offset = 0, tmp_size = 0;
     unsigned char *data_p = NULL;
     
     g_return_val_if_fail(xorigin && yorigin
@@ -3427,12 +3427,20 @@ xfdesktop_get_workarea_single(XfdesktopIconView *icon_view,
                                          &bytes_after, &data_p))
         {
             gint i;
-            gulong *data = (gulong *)data_p;
-            
+            gulong *data;
+
             if(actual_format != 32 || actual_type != XA_CARDINAL) {
                 XFree(data_p);
                 break;
             }
+
+            tmp_size = (actual_format / 8) * nitems;
+            if(actual_format == 32) {
+                tmp_size *= sizeof(long)/4;
+            }
+
+            data = g_malloc(tmp_size);
+            memcpy(data, data_p, tmp_size);
             
             i = offset / 32;  /* first element id in this batch */
             
@@ -3447,11 +3455,13 @@ xfdesktop_get_workarea_single(XfdesktopIconView *icon_view,
                 *height = data[first_id - offset + 3] - 2 * SCREEN_MARGIN;
                 ret = TRUE;
                 XFree(data_p);
+                g_free(data);
                 break;
             }
             
             offset += actual_format * nitems;
             XFree(data_p);
+            g_free(data);
         } else
             break;
     } while(bytes_after > 0);


More information about the Xfce4-commits mailing list