[Spice-devel] [spice-common PATCH] canvas_base: fix not caching palettes that belong to images that are not rendered
Yonit Halperin
yhalperi at redhat.com
Thu Jan 31 08:57:05 PST 2013
Fixes: fedora 875348, 826036
When an image is not rendered, we still need to check if it contains
a palette that needs to be cached.
This bug caused the client to crash due to not finding palettes
in the cache.
---
common/canvas_base.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/common/canvas_base.c b/common/canvas_base.c
index 0ec8526..38a8497 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -1037,8 +1037,24 @@ static SpiceCanvas *canvas_get_surface_mask_internal(CanvasBase *canvas, SpiceIm
return NULL;
}
-#if defined(SW_CANVAS_CACHE) || defined(SW_CANVAS_IMAGE_CACHE)
+#if defined(SW_CANVAS_CACHE)
+static int image_has_palette_to_cache(SpiceImage *image)
+{
+ SpiceImageDescriptor *descriptor = &image->descriptor;
+
+ if (descriptor->type == SPICE_IMAGE_TYPE_BITMAP) {
+ return image->u.bitmap.palette &&
+ (image->u.bitmap.flags & SPICE_BITMAP_FLAGS_PAL_CACHE_ME);
+ } else if (descriptor->type == SPICE_IMAGE_TYPE_LZ_PLT) {
+ return image->u.lz_plt.palette &&
+ (image->u.lz_plt.flags & SPICE_BITMAP_FLAGS_PAL_CACHE_ME);
+ }
+ return FALSE;
+}
+#endif
+
+#if defined(SW_CANVAS_CACHE) || defined(SW_CANVAS_IMAGE_CACHE)
//#define DEBUG_LZ
/* If real get is FALSE, then only do whatever is needed but don't return an image. For instance,
@@ -1064,6 +1080,7 @@ static pixman_image_t *canvas_get_image_internal(CanvasBase *canvas, SpiceImage
!(descriptor->flags & SPICE_IMAGE_FLAGS_CACHE_ME) &&
#ifdef SW_CANVAS_CACHE
!(descriptor->flags & SPICE_IMAGE_FLAGS_CACHE_REPLACE_ME) &&
+ !image_has_palette_to_cache(image) &&
#endif
(descriptor->type != SPICE_IMAGE_TYPE_GLZ_RGB) &&
(descriptor->type != SPICE_IMAGE_TYPE_ZLIB_GLZ_RGB)) {
--
1.8.1
More information about the Spice-devel
mailing list