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
This commit is contained in:
Sebastian Keller 2020-02-03 01:06:14 +01:00 committed by Florian Müllner
parent 9d7a319721
commit 7287ee3651

View File

@ -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