summaryrefslogtreecommitdiff
path: root/src/xfdesktop-icon-view.c
diff options
context:
space:
mode:
authorEric Koegel <eric.koegel@gmail.com>2017-07-18 08:56:57 +0300
committerEric Koegel <eric.koegel@gmail.com>2017-07-18 18:17:53 +0300
commit424208b3e150c48797faeeac7693c5ad6594b3e8 (patch)
treed7e1b42d7f3bdafdfbd7038ea10a4fb1f859dcf8 /src/xfdesktop-icon-view.c
parent1b5faf7fbc61286394c5e84d1d3ad02b3a03779b (diff)
downloadxfdesktop-424208b3e150c48797faeeac7693c5ad6594b3e8.tar.gz
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!
Diffstat (limited to 'src/xfdesktop-icon-view.c')
-rw-r--r--src/xfdesktop-icon-view.c11
1 files 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;
}