ab2acefadde66c992c7ab3ed5a3fca63f6f8a04c
diff --git a/libsoup/soup-cookie-jar-text.c b/libsoup/soup-cookie-jar-text.c
index bf445ae..8d831f1 100644
--- a/libsoup/soup-cookie-jar-text.c
+++ b/libsoup/soup-cookie-jar-text.c
@@ -223,7 +223,8 @@ parse_line (SoupCookieJar *jar, char *line, time_t now)
 	SoupCookie *cookie;
 
 	cookie = parse_cookie (line, now);
-	soup_cookie_jar_add_cookie (jar, cookie);
+	if (cookie)
+		soup_cookie_jar_add_cookie (jar, cookie);
 }
 
 static void
@@ -296,6 +297,7 @@ delete_cookie (const char *filename, SoupCookie *cookie)
 		if (*p == '\r' || *p == '\n') {
 			*p = '\0';
 			c = parse_cookie (line, now);
+			if (!c) continue;
 			if (!soup_cookie_equal (cookie, c))
 				write_cookie (f, c);
 			line = p + 1;
@@ -303,9 +305,11 @@ delete_cookie (const char *filename, SoupCookie *cookie)
 		}
 	}
 	c = parse_cookie (line, now);
-	if (!soup_cookie_equal (cookie, c))
-		write_cookie (f, c);
-	soup_cookie_free (c);
+	if (c) {
+		if (!soup_cookie_equal (cookie, c))
+			write_cookie (f, c);
+		soup_cookie_free (c);
+	}
 
 	g_free (contents);
 	fclose (f);
