From 09d2abdca2a4300fabe1c432cab43c4f3869fb1d Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 21 Feb 2011 17:41:25 +0100 Subject: [PATCH] check return value of getcwd() --- src/config.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/config.c b/src/config.c index ea2dba15..632a7398 100644 --- a/src/config.c +++ b/src/config.c @@ -468,10 +468,12 @@ void configGetCommand(redisClient *c) { if (stringmatch(pattern,"dir",0)) { char buf[1024]; - buf[0] = '\0'; - getcwd(buf,sizeof(buf)); addReplyBulkCString(c,"dir"); - addReplyBulkCString(c,buf); + if (getcwd(buf,sizeof(buf)) == NULL) { + buf[0] = '\0'; + } else { + addReplyBulkCString(c,buf); + } matches++; } if (stringmatch(pattern,"dbfilename",0)) { -- 2.45.2