aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--embed/mozilla/mozilla-embed-persist.cpp27
2 files changed, 21 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 5a7fc141d..9bee02b39 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-06-12 Christian Persch <chpe@cvs.gnome.org>
+
+ * embed/mozilla/mozilla-ember-persist.cpp: (impl_to_string):
+
+ Fix refcount leak.
+
2005-06-11 Christian Persch <chpe@cvs.gnome.org>
* embed/mozilla/mozilla-embed-persist.cpp:
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());
}