[grilo] net: Do not leak content from mockups



commit 6e878f6e04bd88217043b586a9de021423205078
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date:   Sun Sep 1 09:13:49 2013 +0000

    net: Do not leak content from mockups
    
    Be sure content got for mockups are freed to avoid leaks.

 libs/net/grl-net-wc.c |   30 +++++++++++++++---------------
 1 files changed, 15 insertions(+), 15 deletions(-)
---
diff --git a/libs/net/grl-net-wc.c b/libs/net/grl-net-wc.c
index 9c11d46..8721f81 100644
--- a/libs/net/grl-net-wc.c
+++ b/libs/net/grl-net-wc.c
@@ -803,25 +803,28 @@ get_content (GrlNetWc *self,
   GrlNetWcPrivate *priv = self->priv;
   struct request_res *rr = op;
 
-  dump_data (soup_request_get_uri (rr->request),
-             rr->buffer,
-             rr->offset);
-
   if (priv->previous_data)
     g_free (priv->previous_data);
 
-  priv->previous_data = rr->buffer;
+  if (is_mocked ()) {
+    get_content_mocked (self, op, &(priv->previous_data), length);
+  } else {
+    dump_data (soup_request_get_uri (rr->request),
+               rr->buffer,
+               rr->offset);
+    priv->previous_data = rr->buffer;
+    if (length) {
+      *length = rr->offset;
+    }
+  }
 
   if (content)
     *content = self->priv->previous_data;
   else {
-    g_free (rr->buffer);
-    self->priv->previous_data = NULL;
-    rr->buffer = NULL;
+    if (length) {
+      *length = 0;
+    }
   }
-
-  if (length)
-    *length = rr->offset;
 }
 
 /**
@@ -996,10 +999,7 @@ grl_net_wc_request_finish (GrlNetWc *self,
     goto end_func;
   }
 
-  if (is_mocked ())
-    get_content_mocked (self, op, content, length);
-  else
-    get_content(self, op, content, length);
+  get_content(self, op, content, length);
 
 end_func:
   if (is_mocked ())


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]