Fixed error-checking due to the persistence of 'HttpFileHandle'.
authorshort <>
Tue, 2 Sep 2003 21:26:20 +0000 (21:26 +0000)
committershort <>
Tue, 2 Sep 2003 21:26:20 +0000 (21:26 +0000)
modules/http-method.c

index cba1274..d8e0b73 100644 (file)
@@ -2264,6 +2264,7 @@ make_propfind_request (HttpFileHandle *handle,
        xmlNodePtr cur = NULL;
        char *extraheaders = g_strdup_printf("Depth: %d\r\n", depth);
        gboolean found_root_node_props;
+       gboolean handle_valid = FALSE;
 
        GByteArray *request = g_byte_array_new();
        char *request_str = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>"
@@ -2290,6 +2291,8 @@ make_propfind_request (HttpFileHandle *handle,
 
        result = make_request (handle, uri, "PROPFIND", request, 
                               extraheaders, context);
+       if (result == GNOME_VFS_OK)
+               handle_valid = TRUE;
        
        /* FIXME bugzilla.gnome.org 43834: It looks like some http
         * servers (eg, www.yahoo.com) treat PROPFIND as a GET and
@@ -2400,9 +2403,8 @@ cleanup:
        g_free(extraheaders);
        xmlFreeParserCtxt(parserContext);
        
-       if (result != GNOME_VFS_OK) {
+       if (result != GNOME_VFS_OK && handle_valid) {
                http_handle_close (handle, context);
-               g_free (handle);
        }
        
        ANALYZE_HTTP ("==> -make_propfind_request");
@@ -2588,6 +2590,8 @@ do_get_file_info (GnomeVFSMethod *method,
                        g_free (handle);
                        handle = NULL;
                } else {
+                       g_free (handle);
+                       handle = NULL;
                        g_assert (handle == NULL); /* Make sure we're not leaking some old one */
                        
                        /* Lame buggy servers (eg: www.mozilla.org,
@@ -2606,8 +2610,9 @@ do_get_file_info (GnomeVFSMethod *method,
                                        gnome_vfs_file_info_copy (file_info, handle->file_info);
                                        http_cache_add_uri (uri, handle->file_info, FALSE);
                                        http_handle_close (handle, context);
-                                       g_free (handle);
                                }
+                               g_free (handle);
+                               handle = NULL;
 
                                /* If we get a redirect, we should be
                                 * basing the MIME type on the type of