Skip to content

Commit

Permalink
Protection against division by zero when scrolling on an empty thumbt…
Browse files Browse the repository at this point in the history
…able

There are different ways to check if the thumbtable is empty (for example,
whether the thumbnail list is NULL). But we check whether the thumbnail size
is zero as this is exactly what we are interested in, because later we would
have to divide by this value, so we protect ourselves from division by zero.
  • Loading branch information
victoryforce authored and TurboGit committed Feb 4, 2025
1 parent e0b9c23 commit 93fc2ec
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/dtgtk/thumbtable.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of darktable,
Copyright (C) 2024 darktable developers.
Copyright (C) 2024-2025 darktable developers.
darktable is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -1046,9 +1046,15 @@ void dt_thumbtable_zoom_changed(dt_thumbtable_t *table,

static gboolean _event_scroll_compressed(gpointer user_data)
{
if(!user_data) return FALSE;
if(!user_data)
return FALSE;

dt_thumbtable_t *table = user_data;

// Thumbtable is empty, nothing to scroll
if(table->thumb_size == 0)
return FALSE;

if(table->scroll_value != 0)
{
float delta = table->scroll_value;
Expand Down

0 comments on commit 93fc2ec

Please sign in to comment.