From 25cd884f6b494a88bd491a8d9a50486e3f1e6751 Mon Sep 17 00:00:00 2001 From: Jin Qing Date: Fri, 30 Dec 2016 23:13:02 +0800 Subject: Fix __redisSetErrorFromErrno() can not get error string. snprintf() may change errno. --- net.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net.c b/net.c index 7d41209..024f645 100644 --- a/net.c +++ b/net.c @@ -65,12 +65,13 @@ static void redisContextCloseFd(redisContext *c) { } static void __redisSetErrorFromErrno(redisContext *c, int type, const char *prefix) { + int errorno = errno; /* snprintf() may change errno */ char buf[128] = { 0 }; size_t len = 0; if (prefix != NULL) len = snprintf(buf,sizeof(buf),"%s: ",prefix); - __redis_strerror_r(errno, (char *)(buf + len), sizeof(buf) - len); + __redis_strerror_r(errorno, (char *)(buf + len), sizeof(buf) - len); __redisSetError(c,type,buf); } -- cgit v1.2.3