Skip to content

Commit 99eebee

Browse files
bnoordhuiscodebytere
authored andcommitted
src: remove fixed-size GetHumanReadableProcessName
Remove the version of GetHumanReadableProcessName() that operates on a fixed-size buffer. The only remaining caller is Assert() which might get called in contexts where dynamically allocating memory isn't possible but as Assert() calls printf(), which also allocates memory when necessary, this commit is unlikely to make matters much worse. PR-URL: #31633 Fixes: #31631 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent fb53a83 commit 99eebee

File tree

3 files changed

+2
-11
lines changed

3 files changed

+2
-11
lines changed

src/node_errors.cc

+2-3
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,11 @@ void AppendExceptionLine(Environment* env,
242242
}
243243

244244
[[noreturn]] void Assert(const AssertionInfo& info) {
245-
char name[1024];
246-
GetHumanReadableProcessName(&name);
245+
std::string name = GetHumanReadableProcessName();
247246

248247
fprintf(stderr,
249248
"%s: %s:%s%s Assertion `%s' failed.\n",
250-
name,
249+
name.c_str(),
251250
info.file_line,
252251
info.function,
253252
*info.function ? ":" : "",

src/node_internals.h

-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ void RegisterSignalHandler(int signal,
100100

101101
std::string GetProcessTitle(const char* default_title);
102102
std::string GetHumanReadableProcessName();
103-
void GetHumanReadableProcessName(char (*name)[1024]);
104103

105104
void InitializeContextRuntime(v8::Local<v8::Context>);
106105

src/util.cc

-7
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,6 @@ std::string GetHumanReadableProcessName() {
161161
return SPrintF("%s[%d]", GetProcessTitle("Node.js"), uv_os_getpid());
162162
}
163163

164-
void GetHumanReadableProcessName(char (*name)[1024]) {
165-
// Leave room after title for pid, which can be up to 20 digits for 64 bit.
166-
char title[1000] = "Node.js";
167-
uv_get_process_title(title, sizeof(title));
168-
snprintf(*name, sizeof(*name), "%s[%d]", title, uv_os_getpid());
169-
}
170-
171164
std::vector<std::string> SplitString(const std::string& in, char delim) {
172165
std::vector<std::string> out;
173166
if (in.empty())

0 commit comments

Comments
 (0)