Skip to content

Commit 4a632f1

Browse files
author
Ubuntu
committed
Fixed problem with segfault on copy of http_response object
1 parent c5405d2 commit 4a632f1

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/http_response.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ http_response::http_response(const http_response_builder& builder):
6060
enqueue_response(this, builder._enqueue_response),
6161
completed(false),
6262
ws(0x0),
63-
connection_id(0x0)
63+
connection_id(0x0),
64+
_get_raw_response(builder._get_raw_response),
65+
_decorate_response(builder._decorate_response),
66+
_enqueue_response(builder._enqueue_response)
6467
{
6568
}
6669

src/httpserver/http_response.hpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <iosfwd>
3131
#include <stdint.h>
3232
#include <vector>
33+
#include <iostream>
3334

3435
#include "httpserver/binders.hpp"
3536
#include "httpserver/http_utils.hpp"
@@ -91,12 +92,15 @@ class http_response
9192
underlying_connection(b.underlying_connection),
9293
ce(b.ce),
9394
cycle_callback(b.cycle_callback),
94-
get_raw_response(b.get_raw_response),
95-
decorate_response(b.decorate_response),
96-
enqueue_response(b.enqueue_response),
95+
get_raw_response(this, b._get_raw_response),
96+
decorate_response(this, b._decorate_response),
97+
enqueue_response(this, b._enqueue_response),
9798
completed(b.completed),
9899
ws(b.ws),
99-
connection_id(b.connection_id)
100+
connection_id(b.connection_id),
101+
_get_raw_response(b._get_raw_response),
102+
_decorate_response(b._decorate_response),
103+
_enqueue_response(b._enqueue_response)
100104
{
101105
}
102106

@@ -298,6 +302,11 @@ class http_response
298302
http_response& operator=(const http_response& b);
299303

300304
static ssize_t data_generator (void* cls, uint64_t pos, char* buf, size_t max);
305+
306+
void (http_response::*_get_raw_response)(MHD_Response**, webserver*);
307+
void (http_response::*_decorate_response)(MHD_Response*);
308+
int (http_response::*_enqueue_response)(MHD_Connection*, MHD_Response*);
309+
301310
};
302311

303312
std::ostream &operator<< (std::ostream &os, const http_response &r);

0 commit comments

Comments
 (0)