From ff1a92b81efc15460bb30f3b8dfd4363bd431896 Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Wed, 2 Oct 2024 23:21:05 +0000 Subject: [PATCH] libgimpwidgets: Fix infinite loop on appending invalid input gimp_size_entry_eevl_unit_resolver () loops through all valid units to find a match for user's inputted value in GimpSizeEntry. It runs until gimp_unit_get_by_id () returns NULL, where it does a final check on GIMP_UNIT_PERCENT. Due to a small logic error, we kept setting the GimpUnit to gimp_unit_percent () each time it was NULL, so the loop ran forever. Per Jehan, this patch breaks the logic up so that we terminate the loop once the percent check fails. --- libgimpwidgets/gimpsizeentry.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libgimpwidgets/gimpsizeentry.c b/libgimpwidgets/gimpsizeentry.c index 8d9bfb1fba..50f651b038 100644 --- a/libgimpwidgets/gimpsizeentry.c +++ b/libgimpwidgets/gimpsizeentry.c @@ -1547,10 +1547,13 @@ gimp_size_entry_eevl_unit_resolver (const gchar *identifier, return TRUE; } + /* Hack to handle percent within the loop */ + if (unit == gimp_unit_percent ()) + break; + unit = gimp_unit_get_by_id (i++); - /* Hack to handle percent within the loop */ - if (unit == NULL && unit != gimp_unit_percent ()) + if (unit == NULL) unit = gimp_unit_percent (); }