All pastes #1883514 Raw Edit

bob

public text v1 · immutable
#1883514 ·published 2010-06-15 10:57 UTC
rendered paste body
From fac1275822d8f38b8834350a0364d39d1be4e218 Mon Sep 17 00:00:00 2001From: Robert Bragg <robert@linux.intel.com>Date: Tue, 15 Jun 2010 02:31:48 +0100Subject: [PATCH] texture cache: don't dereference item->ptr before NULL checkmx_texture_cache_get_actor would segfault if it failed to find anexisting entry and if clutter_texture_new_from_file() then returned NULL(e.g. due to a missing file). This was because it calledclutter_texture_get_base_size() before the if (!item->ptr) check.This simply defers the _get_base_size() request until after the NULLpointer check.--- mx/mx-texture-cache.c |    5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)diff --git a/mx/mx-texture-cache.c b/mx/mx-texture-cache.cindex e76599c..849ce99 100644--- a/mx/mx-texture-cache.c+++ b/mx/mx-texture-cache.c@@ -396,8 +396,6 @@ mx_texture_cache_get_actor (MxTextureCache *self,   item->posX = -1;   item->posY = -1;   item->ptr = clutter_texture_new_from_file (path, &err);-  clutter_texture_get_base_size (CLUTTER_TEXTURE (item->ptr),-                                 &item->width, &item->height);    if (!item->ptr)     {@@ -410,6 +408,9 @@ mx_texture_cache_get_actor (MxTextureCache *self,       return NULL;     } +  clutter_texture_get_base_size (CLUTTER_TEXTURE (item->ptr),+                                 &item->width, &item->height);+   add_texture_to_cache (self, path, item);    return mx_subtexture_new (CLUTTER_TEXTURE (item->ptr), 0, 0, item->width,-- 1.6.3.3