Skip to content

Commit

Permalink
Fix POST processing of final keys without values
Browse files Browse the repository at this point in the history
'MHD_destroy_post_processor' should be called before the request
callback for ensuring the processing of final keys without terminated
values.
  • Loading branch information
JavierJF committed May 13, 2022
1 parent acc3e6a commit a2dece8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 0 additions & 3 deletions src/httpserver/details/modded_request.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ struct modded_request {
modded_request& operator=(modded_request&& b) = default;

~modded_request() {
if (nullptr != pp) {
MHD_destroy_post_processor(pp);
}
if (second) {
delete dhr;
}
Expand Down
5 changes: 5 additions & 0 deletions src/webserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,11 @@ MHD_Result webserver::finalize_answer(MHD_Connection* connection, struct details
if (found) {
try {
if (hrm->is_allowed(method)) {
if (mr->pp != NULL) {
MHD_destroy_post_processor(mr->pp);
mr->pp = NULL;
}

mr->dhrs = ((hrm)->*(mr->callback))(*mr->dhr); // copy in memory (move in case)
if (mr->dhrs.get() == nullptr || mr->dhrs->get_response_code() == -1) {
mr->dhrs = internal_error_page(mr);
Expand Down

0 comments on commit a2dece8

Please sign in to comment.