From ecdd31b0c95f8f210038bc3dd5dfc0afb7a68883 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Fri, 4 May 2012 17:40:04 +0200 Subject: Adding checks to prevent null pointer dereferences (bzr r11325) --- src/sp-item.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/sp-item.cpp') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index d6395cfee..e0a9b97f2 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -660,15 +660,19 @@ Inkscape::XML::Node *SPItem::sp_item_write(SPObject *const object, Inkscape::XML repr->setAttribute ("inkscape:transform-center-y", NULL); } - if (item->clip_ref->getObject()) { - const gchar *value = g_strdup_printf ("url(%s)", item->clip_ref->getURI()->toString()); - repr->setAttribute ("clip-path", value); - g_free ((void *) value); - } - if (item->mask_ref->getObject()) { - const gchar *value = g_strdup_printf ("url(%s)", item->mask_ref->getURI()->toString()); - repr->setAttribute ("mask", value); - g_free ((void *) value); + if (item->clip_ref){ + if (item->clip_ref->getObject()) { + const gchar *value = g_strdup_printf ("url(%s)", item->clip_ref->getURI()->toString()); + repr->setAttribute ("clip-path", value); + g_free ((void *) value); + } + } + if (item->mask_ref){ + if (item->mask_ref->getObject()) { + const gchar *value = g_strdup_printf ("url(%s)", item->mask_ref->getURI()->toString()); + repr->setAttribute ("mask", value); + g_free ((void *) value); + } } if (((SPObjectClass *) (SPItemClass::static_parent_class))->write) { -- cgit v1.2.3