[Xfce4-commits] [xfce/xfdesktop] 03/03: Don't try to allocate all the memory (Bug #12805)

noreply at xfce.org noreply at xfce.org
Tue Jul 18 17:18:02 CEST 2017


This is an automated email from the git hooks/post-receive script.

e   r   i   c       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository xfce/xfdesktop.

commit 424208b3e150c48797faeeac7693c5ad6594b3e8
Author: Eric Koegel <eric.koegel at gmail.com>
Date:   Tue Jul 18 08:56:57 2017 +0300

    Don't try to allocate all the memory (Bug #12805)
    
    When the screen is removed/killed, our grid size can go negative
    which is problematic. This patch ensures it will always be positive.
    Thanks to haarp for troubleshooting this!
---
 src/xfdesktop-icon-view.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/xfdesktop-icon-view.c b/src/xfdesktop-icon-view.c
index 1aaf018..2c3eb7e 100644
--- a/src/xfdesktop-icon-view.c
+++ b/src/xfdesktop-icon-view.c
@@ -2575,8 +2575,8 @@ xfdesktop_setup_grids(XfdesktopIconView *icon_view)
     icon_view->priv->width = width;
     icon_view->priv->height = height;
 
-    icon_view->priv->nrows = (height - MIN_MARGIN * 2) / CELL_SIZE;
-    icon_view->priv->ncols = (width - MIN_MARGIN * 2) / CELL_SIZE;
+    icon_view->priv->nrows = MAX((height - MIN_MARGIN * 2) / CELL_SIZE, 0);
+    icon_view->priv->ncols = MAX((width - MIN_MARGIN * 2) / CELL_SIZE, 0);
 
     xrest = icon_view->priv->width - icon_view->priv->ncols * CELL_SIZE;
     if (icon_view->priv->ncols > 1) {
@@ -3362,10 +3362,11 @@ xfdesktop_grid_is_free_position(XfdesktopIconView *icon_view,
                                 gint16 row,
                                 gint16 col)
 {
-    g_return_val_if_fail(icon_view->priv->grid_layout != NULL, FALSE);
+    if(icon_view->priv->grid_layout == NULL) {
+        return FALSE;
+    }
 
-    if(row >= icon_view->priv->nrows
-       || col >= icon_view->priv->ncols)
+    if(row >= icon_view->priv->nrows || col >= icon_view->priv->ncols)
     {
         return FALSE;
     }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list