Browse Source

transmit_error_response(): discard read buffer to free space for error response

Evgeny Grin (Karlson2k) 6 năm trước cách đây
mục cha
commit
20767d5dec
1 tập tin đã thay đổi với 10 bổ sung0 xóa
  1. 10 0
      src/microhttpd/connection.c

+ 10 - 0
src/microhttpd/connection.c

@@ -1995,6 +1995,16 @@ transmit_error_response (struct MHD_Connection *connection,
     }
   connection->state = MHD_CONNECTION_FOOTERS_RECEIVED;
   connection->read_closed = true;
+  if (0 != connection->read_buffer_size)
+    {
+      /* Read buffer is not needed anymore, discard it
+       * to free some space for error response. */
+      connection->read_buffer = MHD_pool_reallocate(connection->pool,
+                                                    connection->read_buffer,
+                                                    connection->read_buffer_size,
+                                                    0);
+      connection->read_buffer_size = 0;
+    }
 #ifdef HAVE_MESSAGES
   MHD_DLOG (connection->daemon,
             _("Error processing request (HTTP response code is %u (`%s')). Closing connection.\n"),