c62aa1e5f946faae3bb60faaf8dd3c4b5681de91
diff --git a/libsoup/soup-cookie-jar.c b/libsoup/soup-cookie-jar.c
index 7030555..3b39f6c 100644
--- a/libsoup/soup-cookie-jar.c
+++ b/libsoup/soup-cookie-jar.c
@@ -257,10 +257,10 @@ soup_cookie_jar_add_cookie (SoupCookieJar *jar, SoupCookie *cookie)
 			 * get_cookies_for_domain() will delete it
 			 * later.
 			 */
+			oc->data = cookie;
 			g_signal_emit (jar, signals[CHANGED], 0,
 				       old_cookie, cookie);
 			soup_cookie_free (old_cookie);
-			oc->data = cookie;
 			return;
 		}
 		prev = oc;
@@ -411,13 +411,13 @@ soup_cookie_jar_delete_cookie (SoupCookieJar *jar,
 	for (p = cookies; p; p = p->next ) {
 		SoupCookie *c = (SoupCookie*)p->data;
 		if (soup_cookie_equal (cookie, c)) {
-			g_signal_emit (jar, signals[CHANGED], 0,
-				       c, NULL);
 			cookies = g_slist_delete_link (cookies, p);
-			soup_cookie_free (c);
 			g_hash_table_insert (priv->domains,
 					     domain,
 					     cookies);
+			g_signal_emit (jar, signals[CHANGED], 0,
+				       c, NULL);
+			soup_cookie_free (c);
 			return;
 		}
 	}
