浏览代码

Fixed response leak when upgrade failed

Evgeny Grin (Karlson2k) 8 年之前
父节点
当前提交
e264d9ec9e
共有 1 个文件被更改,包括 3 次插入6 次删除
  1. 3 6
      src/microhttpd/connection.c

+ 3 - 6
src/microhttpd/connection.c

@@ -3161,14 +3161,11 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
 #ifdef UPGRADE_SUPPORT
           if (NULL != connection->response->upgrade_handler)
             {
-              struct MHD_Response *resp_clr = connection->response;
-
               socket_start_normal_buffering (connection);
               connection->state = MHD_CONNECTION_UPGRADE;
-              connection->response = NULL;
               /* This connection is "upgraded".  Pass socket to application. */
               if (MHD_YES !=
-                  MHD_response_execute_upgrade_ (resp_clr,
+                  MHD_response_execute_upgrade_ (connection->response,
                                                  connection))
                 {
                   /* upgrade failed, fail hard */
@@ -3177,8 +3174,8 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
                   continue;
                 }
               /* Response is not required anymore for this connection. */
-              if (NULL != resp_clr)
-                MHD_destroy_response (resp_clr);
+              if (NULL != connection->response)
+                MHD_destroy_response (connection->response);
               continue;
             }
 #endif /* UPGRADE_SUPPORT */