From d2f2a32b897840d91cf240830ad5cf5f0e33a0c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Sun, 2 Mar 2014 23:18:26 +0100 Subject: [PATCH] src: adapt to API change in uv_cwd --- src/node.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/node.cc b/src/node.cc index 6accd4b5f22..6c7eaf3d2d9 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1541,19 +1541,21 @@ static void Cwd(const FunctionCallbackInfo& args) { HandleScope scope(env->isolate()); #ifdef _WIN32 /* MAX_PATH is in characters, not bytes. Make sure we have enough headroom. */ - char buf[MAX_PATH * 4 + 1]; + char buf[MAX_PATH * 4]; #else - char buf[PATH_MAX + 1]; + char buf[PATH_MAX]; #endif - int err = uv_cwd(buf, ARRAY_SIZE(buf) - 1); + size_t cwd_len = sizeof(buf); + int err = uv_cwd(buf, &cwd_len); if (err) { return env->ThrowUVException(err, "uv_cwd"); } - buf[ARRAY_SIZE(buf) - 1] = '\0'; - Local cwd = String::NewFromUtf8(env->isolate(), buf); - + Local cwd = String::NewFromUtf8(env->isolate(), + buf, + String::kNormalString, + cwd_len); args.GetReturnValue().Set(cwd); }