Thank to ValĂ©rian Rousset for pointing this out. Also change the
until_sanitize_uri function to return given uri in case an error occurred
during sanitization process to reduce cases where this function returns
NULL.
         GParamSpec *ps, Client *c)
 {
     spawn_download_command(c, webkit_download_get_response(download));
-       webkit_download_cancel(download);
+    webkit_download_cancel(download);
 }
 
 static void spawn_download_command(Client *c, WebKitURIResponse *response)
     if (c->state.uri) {
         g_free(c->state.uri);
     }
-    gchar *url = util_sanitize_uri(webkit_web_view_get_uri(c->webview));
-    if (!url) {
-        return;
-    }
-    c->state.uri = url;
+
+    c->state.uri = util_sanitize_uri(webkit_web_view_get_uri(c->webview));
 
     update_urlbar(c);
     g_setenv("VIMB_URI", c->state.uri, TRUE);
 
     }
 #if WEBKIT_CHECK_VERSION(2, 24, 0)
     for_display = webkit_uri_for_display(uri_str);
+    if (!for_display) {
+        for_display = g_strdup(uri_str);
+    }
 #else
     for_display = g_strdup(uri_str);
 #endif
-    if (!for_display) {
-           return NULL;
-    }
 
     /* Sanitize the uri only in case there is a @ which might be the indicator
      * for credentials used in uri. */