diff -up libsoup-2.62.2/tests/test-utils.c.coverity-scan-issues libsoup-2.62.2/tests/test-utils.c
--- libsoup-2.62.2/tests/test-utils.c.coverity-scan-issues	2018-03-15 17:46:00.000000000 +0100
+++ libsoup-2.62.2/tests/test-utils.c	2018-06-22 11:40:39.332281529 +0200
@@ -676,9 +679,11 @@ soup_test_request_read_all (SoupRequest
 
 	if (!SOUP_IS_SESSION_SYNC (soup_request_get_session (req)))
 		data.loop = g_main_loop_new (g_main_context_get_thread_default (), FALSE);
+	else
+		data.loop = NULL;
 
 	do {
-		if (SOUP_IS_SESSION_SYNC (soup_request_get_session (req))) {
+		if (!data.loop) {
 			nread = g_input_stream_read (stream, buf, sizeof (buf),
 						     cancellable, error);
 		} else {
@@ -691,7 +696,7 @@ soup_test_request_read_all (SoupRequest
 		}
 	} while (nread > 0);
 
-	if (!SOUP_IS_SESSION_SYNC (soup_request_get_session (req)))
+	if (data.loop)
 		g_main_loop_unref (data.loop);
 
 	return nread == 0;
