From 8a8cff4b34c6dbaf6d31a2c9dda8afa3b1509cf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Thu, 16 Oct 2014 14:18:27 +0200 Subject: [PATCH] unix, windows: don't include null byte in uv_cwd size Make it consistent with uv_exepath --- src/unix/core.c | 2 +- src/win/util.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/unix/core.c b/src/unix/core.c index 9dcc3935dc..7add085fea 100644 --- a/src/unix/core.c +++ b/src/unix/core.c @@ -637,7 +637,7 @@ int uv_cwd(char* buffer, size_t* size) { if (getcwd(buffer, *size) == NULL) return -errno; - *size = strlen(buffer) + 1; + *size = strlen(buffer); return 0; } diff --git a/src/win/util.c b/src/win/util.c index 8fb7f82621..b7dba7bbda 100644 --- a/src/win/util.c +++ b/src/win/util.c @@ -206,7 +206,7 @@ int uv_cwd(char* buffer, size_t* size) { if (r == 0) { return uv_translate_sys_error(GetLastError()); } else if (r > (int) *size) { - *size = r; + *size = r -1; return UV_ENOBUFS; } @@ -223,7 +223,7 @@ int uv_cwd(char* buffer, size_t* size) { return uv_translate_sys_error(GetLastError()); } - *size = r; + *size = r - 1; return 0; }