check return value of getcwd()
authorantirez <antirez@gmail.com>
Mon, 21 Feb 2011 16:41:25 +0000 (17:41 +0100)
committerantirez <antirez@gmail.com>
Mon, 21 Feb 2011 16:51:28 +0000 (17:51 +0100)
src/config.c

index ea2dba15099db25dec1104337b79956ad1d56dec..632a739890c2992c86f9342fd681fd987ed4680e 100644 (file)
@@ -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)) {