diff --git a/src/node_file.cc b/src/node_file.cc index 77d11756a2dbe5..d1a12098bbf771 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -433,21 +433,19 @@ Local BuildStatsObject(Environment* env, const uv_stat_t* s) { // crash(); // } // - // We need to check the return value of Integer::New() and Date::New() + // We need to check the return value of Number::New() and Date::New() // and make sure that we bail out when V8 returns an empty handle. - // Integers. + // Unsigned integers. It does not actually seem to be specified whether + // uid and gid are unsigned or not, but in practice they are unsigned, + // and Node’s (F)Chown functions do check their arguments for unsignedness. #define X(name) \ - Local name = Integer::New(env->isolate(), s->st_##name); \ + Local name = Integer::NewFromUnsigned(env->isolate(), s->st_##name); \ if (name.IsEmpty()) \ - return handle_scope.Escape(Local()); \ + return Local(); \ - X(dev) - X(mode) - X(nlink) X(uid) X(gid) - X(rdev) # if defined(__POSIX__) X(blksize) # else @@ -455,12 +453,24 @@ Local BuildStatsObject(Environment* env, const uv_stat_t* s) { # endif #undef X + // Integers. +#define X(name) \ + Local name = Integer::NewFromUnsigned(env->isolate(), s->st_##name); \ + if (name.IsEmpty()) \ + return Local(); \ + + X(dev) + X(mode) + X(nlink) + X(rdev) +#undef X + // Numbers. #define X(name) \ Local name = Number::New(env->isolate(), \ static_cast(s->st_##name)); \ if (name.IsEmpty()) \ - return handle_scope.Escape(Local()); \ + return Local(); \ X(ino) X(size) @@ -479,7 +489,7 @@ Local BuildStatsObject(Environment* env, const uv_stat_t* s) { (static_cast(s->st_##name.tv_nsec / 1000000))); \ \ if (name##_msec.IsEmpty()) \ - return handle_scope.Escape(Local()); \ + return Local(); \ X(atim) X(mtim)