Skip to content

Commit 01902bb

Browse files
authored
Merge pull request #3289 from hgarrereyn/master
fix wrong call and undefined use of va_args in mg_queue_vprintf
2 parents e28e9aa + 587e79d commit 01902bb

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

mongoose.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7812,7 +7812,9 @@ bool mg_ota_end(void) {
78127812

78137813

78147814
size_t mg_queue_vprintf(struct mg_queue *q, const char *fmt, va_list *ap) {
7815-
size_t len = mg_snprintf(NULL, 0, fmt, ap);
7815+
va_list ap_copy;
7816+
va_copy(ap_copy, *ap);
7817+
size_t len = mg_vsnprintf(NULL, 0, fmt, &ap_copy);
78167818
char *buf;
78177819
if (len == 0 || mg_queue_book(q, &buf, len + 1) < len + 1) {
78187820
len = 0; // Nah. Not enough space

src/printf.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
#include "util.h"
44

55
size_t mg_queue_vprintf(struct mg_queue *q, const char *fmt, va_list *ap) {
6-
size_t len = mg_snprintf(NULL, 0, fmt, ap);
6+
va_list ap_copy;
7+
va_copy(ap_copy, *ap);
8+
size_t len = mg_vsnprintf(NULL, 0, fmt, &ap_copy);
79
char *buf;
810
if (len == 0 || mg_queue_book(q, &buf, len + 1) < len + 1) {
911
len = 0; // Nah. Not enough space

0 commit comments

Comments
 (0)