[gnome-shell] texture-cache: Fix invalid reads when storing used resource scales



commit 7287ee365103909c4c3e540a3f7958957f601435
Author: Sebastian Keller <skeller gnome org>
Date:   Mon Feb 3 01:06:14 2020 +0100

    texture-cache: Fix invalid reads when storing used resource scales
    
    The used_scales hash table uses g_double_hash and g_double_equal which
    try to read a double from the passed pointers. The pointers however were
    pointing to a float, leading to an invalid read.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/974

 src/st/st-texture-cache.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/src/st/st-texture-cache.c b/src/st/st-texture-cache.c
index 01d193851e..7f957bff74 100644
--- a/src/st/st-texture-cache.c
+++ b/src/st/st-texture-cache.c
@@ -1443,8 +1443,9 @@ st_texture_cache_load_file_sync_to_cogl_texture (StTextureCache *cache,
 
       if (policy == ST_TEXTURE_CACHE_POLICY_FOREVER)
         {
+          double resource_scale_double = resource_scale;
           g_hash_table_insert (cache->priv->keyed_cache, g_strdup (key), image);
-          g_hash_table_insert (cache->priv->used_scales, &resource_scale, &resource_scale);
+          g_hash_table_insert (cache->priv->used_scales, &resource_scale_double, &resource_scale_double);
         }
     }
 
@@ -1491,10 +1492,11 @@ st_texture_cache_load_file_sync_to_cairo_surface (StTextureCache        *cache,
 
       if (policy == ST_TEXTURE_CACHE_POLICY_FOREVER)
         {
+          double resource_scale_double = resource_scale;
           cairo_surface_reference (surface);
           g_hash_table_insert (cache->priv->keyed_surface_cache,
                                g_strdup (key), surface);
-          g_hash_table_insert (cache->priv->used_scales, &resource_scale, &resource_scale);
+          g_hash_table_insert (cache->priv->used_scales, &resource_scale_double, &resource_scale_double);
         }
     }
   else


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