From 71042fbc62f39332b72c5b62139cb01b627e3dcf Mon Sep 17 00:00:00 2001 From: Eric Koegel Date: Tue, 18 Jul 2017 08:56:57 +0300 Subject: [PATCH 3/3] 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 1aaf0185..2c3eb7ec 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; } -- 2.11.0