Skip to content

Commit bc6105e

Browse files
committed
src: map UINT64_MAX to 0 in process.constrainedMemory()
When uv_get_constrained_memory() returns UINT64_MAX, it indicates there is a constraining mechanism but no constraint is set. Per the Node.js documentation, this should return 0 instead of exposing the raw UINT64_MAX value to JavaScript. Fixes: #59227
1 parent 3bbed16 commit bc6105e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/node_process_methods.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#endif
2323

2424
#include <climits> // PATH_MAX
25+
#include <cstdint> // UINT64_MAX
2526
#include <cstdio>
2627

2728
#if defined(_MSC_VER)
@@ -250,6 +251,7 @@ static void MemoryUsage(const FunctionCallbackInfo<Value>& args) {
250251

251252
static void GetConstrainedMemory(const FunctionCallbackInfo<Value>& args) {
252253
uint64_t value = uv_get_constrained_memory();
254+
if (value == UINT64_MAX) value = 0;
253255
args.GetReturnValue().Set(static_cast<double>(value));
254256
}
255257

0 commit comments

Comments
 (0)