From e647cfe241e6bf42f3b2932d7891d73597bd8ae9 Mon Sep 17 00:00:00 2001 From: joncruz Date: Fri, 6 Apr 2007 20:12:18 +0000 Subject: [PATCH] Additional null pointer checking --- src/inkscape.cpp | 7 ++++++- src/sp-style-elem-test.h | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 829aacdc9..c167be493 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -731,7 +731,12 @@ inkscape_get_repr (Inkscape::Application *inkscape, const gchar *key) return NULL; } - Inkscape::XML::Node *repr = Inkscape::Preferences::get()->root(); + Inkscape::XML::Node *prefs = Inkscape::Preferences::get(); + if ( !prefs ) { + return NULL; + } + + Inkscape::XML::Node *repr = prefs->root(); if (!repr) return NULL; g_assert (!(strcmp (repr->name(), "inkscape"))); diff --git a/src/sp-style-elem-test.h b/src/sp-style-elem-test.h index 8f52e8afd..755fe4418 100644 --- a/src/sp-style-elem-test.h +++ b/src/sp-style-elem-test.h @@ -73,6 +73,12 @@ public: void testWrite() { + TS_ASSERT( _doc ); + TS_ASSERT( sp_document_repr_doc(_doc) ); + if ( !sp_document_repr_doc(_doc) ) { + return; // evil early return + } + SPStyleElem *style_elem = SP_STYLE_ELEM(g_object_new(SP_TYPE_STYLE_ELEM, NULL)); SP_OBJECT(style_elem)->document = _doc; @@ -93,6 +99,12 @@ public: void testBuild() { + TS_ASSERT( _doc ); + TS_ASSERT( sp_document_repr_doc(_doc) ); + if ( !sp_document_repr_doc(_doc) ) { + return; // evil early return + } + SPStyleElem &style_elem = *SP_STYLE_ELEM(g_object_new(SP_TYPE_STYLE_ELEM, NULL)); Inkscape::XML::Node *const repr = sp_document_repr_doc(_doc)->createElement("svg:style"); repr->setAttribute("type", "text/css"); @@ -115,6 +127,12 @@ public: void testReadContent() { + TS_ASSERT( _doc ); + TS_ASSERT( sp_document_repr_doc(_doc) ); + if ( !sp_document_repr_doc(_doc) ) { + return; // evil early return + } + SPStyleElem &style_elem = *SP_STYLE_ELEM(g_object_new(SP_TYPE_STYLE_ELEM, NULL)); Inkscape::XML::Node *const repr = sp_document_repr_doc(_doc)->createElement("svg:style"); repr->setAttribute("type", "text/css"); -- 2.30.2