From b2ab4848834fb67580bb79aba30d1604eb5600d5 Mon Sep 17 00:00:00 2001 From: cpq Date: Thu, 24 Dec 2020 19:10:54 +0000 Subject: [PATCH] Fix #954 --- mongoose.c | 2 +- src/util.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mongoose.c b/mongoose.c index 1d27a8a3..b422a409 100644 --- a/mongoose.c +++ b/mongoose.c @@ -3733,7 +3733,7 @@ int mg_vasprintf(char **buf, size_t size, const char *fmt, va_list ap) { } // Microsoft version of vsnprintf() is not always null-terminated, so put // the terminator manually - (*buf)[len] = 0; + if (*buf != NULL) (*buf)[len] = 0; // LCOV_EXCL_STOP } else if (len >= (int) size) { /// Standard-compliant code path. Allocate a buffer that is large enough diff --git a/src/util.c b/src/util.c index dd156514..c5180f26 100644 --- a/src/util.c +++ b/src/util.c @@ -190,7 +190,7 @@ int mg_vasprintf(char **buf, size_t size, const char *fmt, va_list ap) { } // Microsoft version of vsnprintf() is not always null-terminated, so put // the terminator manually - (*buf)[len] = 0; + if (*buf != NULL) (*buf)[len] = 0; // LCOV_EXCL_STOP } else if (len >= (int) size) { /// Standard-compliant code path. Allocate a buffer that is large enough