From f840d4880df21b49514aa9c7f937ea02d1e45b7a Mon Sep 17 00:00:00 2001 From: Ting-Wei Lan Date: Fri, 16 Jan 2015 16:14:45 +0800 Subject: HW1+: 避免在工作目錄被刪除時印出亂碼 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hw1/xwrap.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw1/xwrap.c b/hw1/xwrap.c index 85991ae..dfdf2c8 100644 --- a/hw1/xwrap.c +++ b/hw1/xwrap.c @@ -107,5 +107,9 @@ char* xgetcwd (void) { cwd = xrealloc (cwd, size); } + if (result == NULL) { + strncpy (cwd, "", size - 1); + } + return cwd; } -- cgit