mirror of
https://github.com/cesanta/mongoose.git
synced 2025-08-06 13:37:34 +08:00
Fix issue #338
This commit is contained in:
parent
725c30446c
commit
dbbda02f70
@ -2262,11 +2262,13 @@ void mg_printf_data(struct mg_connection *c, const char *fmt, ...) {
|
|||||||
struct connection *conn = MG_CONN_2_CONN(c);
|
struct connection *conn = MG_CONN_2_CONN(c);
|
||||||
struct iobuf *io = &conn->ns_conn->send_iobuf;
|
struct iobuf *io = &conn->ns_conn->send_iobuf;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int len, n;
|
int len, n, iolen;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
terminate_headers(c);
|
terminate_headers(c);
|
||||||
|
|
||||||
|
// Remember original io->len
|
||||||
|
iolen = io->len;
|
||||||
// Write the placeholder for the chunk size
|
// Write the placeholder for the chunk size
|
||||||
p = io->buf + io->len;
|
p = io->buf + io->len;
|
||||||
iobuf_append(io, " \r\n", 10);
|
iobuf_append(io, " \r\n", 10);
|
||||||
@ -2276,6 +2278,9 @@ void mg_printf_data(struct mg_connection *c, const char *fmt, ...) {
|
|||||||
len = ns_vprintf(conn->ns_conn, fmt, ap);
|
len = ns_vprintf(conn->ns_conn, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
|
// Recalculate pointer p because of potential realloc within iobuf_append
|
||||||
|
p = io->buf + iolen;
|
||||||
|
|
||||||
// Record size
|
// Record size
|
||||||
n = mg_snprintf(p, 7, "%X", len);
|
n = mg_snprintf(p, 7, "%X", len);
|
||||||
p[n] = ' ';
|
p[n] = ' ';
|
||||||
|
Loading…
Reference in New Issue
Block a user