From 9f3baf2ee3e0157d2f3f37ffdafdce502a17f4ad Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Wed, 11 Nov 2015 15:06:10 +0800 Subject: [PATCH] fix issue #372 --- skynet-src/skynet_error.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/skynet-src/skynet_error.c b/skynet-src/skynet_error.c index 962ea597..856c4700 100644 --- a/skynet-src/skynet_error.c +++ b/skynet-src/skynet_error.c @@ -28,7 +28,7 @@ skynet_error(struct skynet_context * context, const char *msg, ...) { va_start(ap,msg); int len = vsnprintf(tmp, LOG_MESSAGE_SIZE, msg, ap); va_end(ap); - if (len < LOG_MESSAGE_SIZE) { + if (len >=0 && len < LOG_MESSAGE_SIZE) { data = skynet_strdup(tmp); } else { int max_size = LOG_MESSAGE_SIZE; @@ -44,6 +44,11 @@ skynet_error(struct skynet_context * context, const char *msg, ...) { skynet_free(data); } } + if (len < 0) { + skynet_free(data); + perror("vsnprintf error :"); + return; + } struct skynet_message smsg;