[gimp] libgimpwidgets: fix segfaults on wrongly handled referencing.



commit 6a08fd6596f8881e7520784f0dbb01702c0407e3
Author: Jehan <jehan girinstud io>
Date:   Mon Jul 18 14:33:42 2022 +0200

    libgimpwidgets: fix segfaults on wrongly handled referencing.
    
    gimp_color_config_get_simulation_color_profile() is returning a new
    object, so we had 2 code paths giving either allocated data or not.
    
    Therefore simply ref the passed softproof profile in the second code
    path, and don't ref it anymore when caching it (especially as it might
    also be NULL at that point).

 libgimpwidgets/gimpwidgetsutils.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/libgimpwidgets/gimpwidgetsutils.c b/libgimpwidgets/gimpwidgetsutils.c
index bc7038bf9a..33b0e606cf 100644
--- a/libgimpwidgets/gimpwidgetsutils.c
+++ b/libgimpwidgets/gimpwidgetsutils.c
@@ -901,7 +901,7 @@ gimp_widget_get_color_transform (GtkWidget        *widget,
         proof_profile = gimp_color_config_get_simulation_color_profile (config,
                                                                         NULL);
       else
-        proof_profile = softproof_profile;
+        proof_profile = g_object_ref (softproof_profile);
       /*  fallthru  */
 
     case GIMP_COLOR_MANAGEMENT_DISPLAY:
@@ -947,7 +947,7 @@ gimp_widget_get_color_transform (GtkWidget        *widget,
   cache->src_format    = src_format;
   cache->dest_profile  = dest_profile;
   cache->dest_format   = dest_format;
-  cache->proof_profile = g_object_ref (proof_profile);
+  cache->proof_profile = proof_profile;
 
   cache->notify_id =
     g_signal_connect (cache->config, "notify",


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]