Title: [143243] trunk/Source/WebCore
Revision
143243
Author
ch.du...@sisa.samsung.com
Date
2013-02-18 11:01:23 -0800 (Mon, 18 Feb 2013)

Log Message

[Soup] Free cookies explicitly in loops instead of using GOwnPtr
https://bugs.webkit.org/show_bug.cgi?id=110103

Reviewed by Martin Robinson.

Free cookies explicitly in loops instead of using GOwnPtr for this.
Until now, the code was mixing both styles. This patch makes the
code consistent one way. Adopting list items with GOwnPtr for the
sole purpose to free them makes the freeing less obvious and may
lead to mistakes if someone refactors the code and calls "break;"
to abort loop iteration.

No new tests, no behavior change.

* platform/network/soup/CookieJarSoup.cpp:
(WebCore::getRawCookies):
(WebCore::deleteCookie):
(WebCore::getHostnamesWithCookies):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (143242 => 143243)


--- trunk/Source/WebCore/ChangeLog	2013-02-18 18:43:50 UTC (rev 143242)
+++ trunk/Source/WebCore/ChangeLog	2013-02-18 19:01:23 UTC (rev 143243)
@@ -1,3 +1,24 @@
+2013-02-18  Christophe Dumez  <ch.du...@sisa.samsung.com>
+
+        [Soup] Free cookies explicitly in loops instead of using GOwnPtr
+        https://bugs.webkit.org/show_bug.cgi?id=110103
+
+        Reviewed by Martin Robinson.
+
+        Free cookies explicitly in loops instead of using GOwnPtr for this.
+        Until now, the code was mixing both styles. This patch makes the
+        code consistent one way. Adopting list items with GOwnPtr for the
+        sole purpose to free them makes the freeing less obvious and may
+        lead to mistakes if someone refactors the code and calls "break;"
+        to abort loop iteration.
+
+        No new tests, no behavior change.
+
+        * platform/network/soup/CookieJarSoup.cpp:
+        (WebCore::getRawCookies):
+        (WebCore::deleteCookie):
+        (WebCore::getHostnamesWithCookies):
+
 2013-02-18  Joseph Pecoraro  <pecor...@apple.com>
 
         [JSC]: ASSERT in KURL(ParsedURLStringTag) under sourceMapURLForScript

Modified: trunk/Source/WebCore/platform/network/soup/CookieJarSoup.cpp (143242 => 143243)


--- trunk/Source/WebCore/platform/network/soup/CookieJarSoup.cpp	2013-02-18 18:43:50 UTC (rev 143242)
+++ trunk/Source/WebCore/platform/network/soup/CookieJarSoup.cpp	2013-02-18 19:01:23 UTC (rev 143243)
@@ -148,10 +148,11 @@
         return false;
 
     for (GSList* iter = cookies.get(); iter; iter = g_slist_next(iter)) {
-        GOwnPtr<SoupCookie> cookie(static_cast<SoupCookie*>(iter->data));
+        SoupCookie* cookie = static_cast<SoupCookie*>(iter->data);
         rawCookies.append(Cookie(String::fromUTF8(cookie->name), String::fromUTF8(cookie->value), String::fromUTF8(cookie->domain),
                                  String::fromUTF8(cookie->path), static_cast<double>(soup_date_to_time_t(cookie->expires)) * 1000,
                                  cookie->http_only, cookie->secure, soup_cookie_jar_is_persistent(jar)));
+        soup_cookie_free(cookie);
     }
 
     return true;
@@ -171,11 +172,12 @@
     CString cookieName = name.utf8();
     bool wasDeleted = false;
     for (GSList* iter = cookies.get(); iter; iter = g_slist_next(iter)) {
-        GOwnPtr<SoupCookie> cookie(static_cast<SoupCookie*>(iter->data));
+        SoupCookie* cookie = static_cast<SoupCookie*>(iter->data);
         if (!wasDeleted && cookieName == cookie->name) {
-            soup_cookie_jar_delete_cookie(jar, cookie.get());
+            soup_cookie_jar_delete_cookie(jar, cookie);
             wasDeleted = true;
         }
+        soup_cookie_free(cookie);
     }
 }
 
@@ -184,10 +186,10 @@
     SoupCookieJar* cookieJar = cookieJarForSession(session);
     GOwnPtr<GSList> cookies(soup_cookie_jar_all_cookies(cookieJar));
     for (GSList* item = cookies.get(); item; item = g_slist_next(item)) {
-        GOwnPtr<SoupCookie> cookie(static_cast<SoupCookie*>(item->data));
-        if (!cookie->domain)
-            continue;
-        hostnames.add(String::fromUTF8(cookie->domain));
+        SoupCookie* cookie = static_cast<SoupCookie*>(item->data);
+        if (cookie->domain)
+            hostnames.add(String::fromUTF8(cookie->domain));
+        soup_cookie_free(cookie);
     }
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to