From cb9756402b60be2b2ed8d058c1de4133ae3c0300 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 3 Mar 2014 22:08:39 +0100 Subject: - fix memleak - fix { } usage - delete NULL is guaranteed to be OK - fix initialization (all paths will eventually init the var, but let the compiler figure that out, instead of a future programmer trying to locate a bug) (bzr r13101) --- src/uri-references.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/uri-references.cpp') diff --git a/src/uri-references.cpp b/src/uri-references.cpp index 5cdf132fa..8edafb0b0 100644 --- a/src/uri-references.cpp +++ b/src/uri-references.cpp @@ -71,13 +71,15 @@ void URIReference::attach(const URI &uri) throw(BadURIException) if(document && uri.getPath() && !skip ) { std::string base = document->getBase() ? document->getBase() : ""; std::string path = uri.getFullPath(base); - if(!path.empty()) + if(!path.empty()) { document = document->createChildDoc(path); - else + } else { document = NULL; + } } if(!document) { g_warning("Can't get document for referenced URI: %s", filename); + g_free( filename ); return; } g_free( filename ); @@ -91,7 +93,7 @@ void URIReference::attach(const URI &uri) throw(BadURIException) /* for now this handles the minimal xpointer form that SVG 1.0 * requires of us */ - gchar *id; + gchar *id = NULL; if (!strncmp(fragment, "xpointer(", 9)) { /* FIXME !!! this is wasteful */ /* FIXME: It looks as though this is including "))" in the id. I suggest moving @@ -113,9 +115,7 @@ void URIReference::attach(const URI &uri) throw(BadURIException) /* FIXME !!! validate id as an NCName somewhere */ - if (_uri) { - delete _uri; - } + delete _uri; _uri = new URI(uri); _connection.disconnect(); -- cgit v1.2.3 From 7c4b51c7574844efd991df787e9be4c96fb031b3 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 3 Mar 2014 22:21:55 +0100 Subject: change 0 to NULL for pointers (bzr r13102) --- src/uri-references.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/uri-references.cpp') diff --git a/src/uri-references.cpp b/src/uri-references.cpp index 8edafb0b0..1da890c56 100644 --- a/src/uri-references.cpp +++ b/src/uri-references.cpp @@ -172,7 +172,7 @@ void URIReference::_release(SPObject *obj) SPObject* sp_css_uri_reference_resolve( SPDocument *document, const gchar *uri ) { - SPObject* ref = 0; + SPObject* ref = NULL; if ( document && uri && ( strncmp(uri, "url(", 4) == 0 ) ) { gchar *trimmed = extract_uri( uri ); @@ -188,7 +188,7 @@ SPObject* sp_css_uri_reference_resolve( SPDocument *document, const gchar *uri ) SPObject * sp_uri_reference_resolve (SPDocument *document, const gchar *uri) { - SPObject* ref = 0; + SPObject* ref = NULL; if ( uri && (*uri == '#') ) { ref = document->getObjectById( uri + 1 ); -- cgit v1.2.3