diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2005-06-13 03:25:40 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2005-06-13 03:25:40 +0800 |
commit | cc9aa1b769472f1a460c4537da90847dc52d7b6f (patch) | |
tree | ec761d6ef8997605352550388ae7ca473f8d8451 /embed | |
parent | f208a356f3aebec4c15a59403c8dd30c3a0cc2c3 (diff) | |
download | gsoc2013-epiphany-cc9aa1b769472f1a460c4537da90847dc52d7b6f.tar.gz gsoc2013-epiphany-cc9aa1b769472f1a460c4537da90847dc52d7b6f.tar.zst gsoc2013-epiphany-cc9aa1b769472f1a460c4537da90847dc52d7b6f.zip |
Fix refcount leak.
2005-06-12 Christian Persch <chpe@cvs.gnome.org>
* embed/mozilla/mozilla-ember-persist.cpp: (impl_to_string):
Fix refcount leak.
Diffstat (limited to 'embed')
-rw-r--r-- | embed/mozilla/mozilla-embed-persist.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/embed/mozilla/mozilla-embed-persist.cpp b/embed/mozilla/mozilla-embed-persist.cpp index 44fd0e2ec..7c20d2f81 100644 --- a/embed/mozilla/mozilla-embed-persist.cpp +++ b/embed/mozilla/mozilla-embed-persist.cpp @@ -304,10 +304,10 @@ impl_to_string (EphyEmbedPersist *persist) "embed", &embed, NULL); g_object_unref (persist); - g_assert (embed != NULL); + g_return_val_if_fail (embed != NULL, NULL); browser = (EphyBrowser *) _mozilla_embed_get_ephy_browser (MOZILLA_EMBED(embed)); - g_assert (browser != NULL); + g_return_val_if_fail (browser != NULL, NULL); if (flags & EPHY_EMBED_PERSIST_MAINDOC) { @@ -317,20 +317,23 @@ impl_to_string (EphyEmbedPersist *persist) { rv = browser->GetTargetDocument (getter_AddRefs(DOMDocument)); } - if (NS_FAILED(rv) || !DOMDocument) return NULL; + nsEmbedCString cOutString; nsCOMPtr<nsIDOMNode> node = do_QueryInterface(DOMDocument); - if (!node) return NULL; - - nsCOMPtr<nsIDOMSerializer> serializer; - serializer = do_CreateInstance(NS_XMLSERIALIZER_CONTRACTID, &rv); - NS_ENSURE_SUCCESS (rv, FALSE); + if (node) + { + nsEmbedString outString; + nsCOMPtr<nsIDOMSerializer> serializer; + serializer = do_CreateInstance(NS_XMLSERIALIZER_CONTRACTID, &rv); + if (serializer) + { + serializer->SerializeToString(node, outString); - nsEmbedString outString; - serializer->SerializeToString(node, outString); + NS_UTF16ToCString (outString, NS_CSTRING_ENCODING_UTF8, cOutString); + } + } - nsEmbedCString cOutString; - NS_UTF16ToCString (outString, NS_CSTRING_ENCODING_UTF8, cOutString); + g_object_unref (embed); return g_strdup (cOutString.get()); } |