Commit 37f7f3fb authored by Sergey Lyubka's avatar Sergey Lyubka

Merge pull request #339 from nenioscio/master

Fix issue #338
parents 2ac970fa dbbda02f
......@@ -2264,11 +2264,13 @@ void mg_printf_data(struct mg_connection *c, const char *fmt, ...) {
struct connection *conn = MG_CONN_2_CONN(c);
struct iobuf *io = &conn->ns_conn->send_iobuf;
va_list ap;
int len, n;
int len, n, iolen;
char *p;
terminate_headers(c);
// Remember original io->len
iolen = io->len;
// Write the placeholder for the chunk size
p = io->buf + io->len;
iobuf_append(io, " \r\n", 10);
......@@ -2278,6 +2280,9 @@ void mg_printf_data(struct mg_connection *c, const char *fmt, ...) {
len = ns_vprintf(conn->ns_conn, fmt, ap);
va_end(ap);
// Recalculate pointer p because of potential realloc within iobuf_append
p = io->buf + iolen;
// Record size
n = mg_snprintf(p, 7, "%X", len);
p[n] = ' ';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment