| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 108b883 commit 9f9a960
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,6 +27,7 @@ | |||
| 27 | 27 | #include "node.h" | |
| 28 | 28 | #include "node_external_reference.h" | |
| 29 | 29 | #include "node_profiling.h" | |
| 30 | + #include "permission/permission.h" | ||
| 30 | 31 | #include "util-inl.h" | |
| 31 | 32 | #include "v8-profiler.h" | |
| 32 | 33 | #include "v8.h" | |
@@ -199,6 +200,14 @@ void SetHeapSnapshotNearHeapLimit(const FunctionCallbackInfo<Value>& args) { | |||
| 199 | 200 | Environment* env = Environment::GetCurrent(args); | |
| 200 | 201 | uint32_t limit = args[0].As<v8::Uint32>()->Value(); | |
| 201 | 202 | CHECK_GT(limit, 0); | |
| 203 | + | ||
| 204 | + std::string dir = env->options()->diagnostic_dir; | ||
| 205 | + if (dir.empty()) { | ||
| 206 | + dir = Environment::GetCwd(env->exec_path()); | ||
| 207 | + } | ||
| 208 | + THROW_IF_INSUFFICIENT_PERMISSIONS( | ||
| 209 | + env, permission::PermissionScope::kFileSystemWrite, dir); | ||
| 210 | + | ||
| 202 | 211 | env->AddHeapSnapshotNearHeapLimitCallback(); | |
| 203 | 212 | env->set_heap_snapshot_near_heap_limit(limit); | |
| 204 | 213 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,3 +34,12 @@ const path = require('path'); | |||
| 34 | 34 | permission: 'FileSystemWrite', | |
| 35 | 35 | })); | |
| 36 | 36 | } | |
| 37 | + | ||
| 38 | + { | ||
| 39 | + assert.throws(() => { | ||
| 40 | + v8.setHeapSnapshotNearHeapLimit(1); | ||
| 41 | + }, common.expectsError({ | ||
| 42 | + code: 'ERR_ACCESS_DENIED', | ||
| 43 | + permission: 'FileSystemWrite', | ||
| 44 | + })); | ||
| 45 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments