Browse Source

Use C memory allocation instead of C++, so std::bad_alloc exception handling must not be done

bel 11 năm trước cách đây
mục cha
commit
2a4b819ef9
1 tập tin đã thay đổi với 3 bổ sung3 xóa
  1. 3 3
      src/CivetServer.cpp

+ 3 - 3
src/CivetServer.cpp

@@ -97,7 +97,7 @@ void CivetServer::closeHandler(struct mg_connection *conn)
 
     if (me->userCloseHandler) me->userCloseHandler(conn);
     if (me->postData) {
-        delete [] (me->postData);
+        free(me->postData);
         me->postData = 0;
     }
 }
@@ -182,9 +182,9 @@ CivetServer::getParam(struct mg_connection *conn, const char *name,
         if (con_len_str) {
             unsigned long con_len = atoi(con_len_str);
             if (con_len>0) {
-                me->postData = new char[con_len];
+                me->postData = (char*)malloc(con_len);
                 if (me->postData != NULL) {
-                    /* NULL check is not required according to current C++ standard */
+                    /* malloc may fail for huge requests */
                     mg_read(conn, me->postData, con_len);
                     formParams = me->postData;
                 }