fix off-by-one error introduced in #328 (Safari only)

closes #346
This commit is contained in:
Jan-Piet Mens
2020-07-01 16:40:23 +02:00
parent 47a82d12cd
commit 31f453ccd3

2
http.c
View File

@@ -371,7 +371,7 @@ static int json_response(struct mg_connection *conn, JsonNode *json)
size_t content_length = strlen(js);
int length = snprintf(NULL, 0, "%zu", content_length);
char buffer[length + 1];
snprintf(buffer, length, "%zu", content_length);
snprintf(buffer, length + 1, "%zu", content_length);
mg_send_header(conn, "Content-Length", buffer);
mg_printf_data(conn, js);
free(js);