Skip to content

Commit

Permalink
Fix null terminator in Demangle function.
Browse files Browse the repository at this point in the history
If the demangled name is longer than out_size, the null terminator is
missing from the output. This will cause a crash in the DemangleInplace()
function (symbolize.cc) when calling strlen on the buffer.
  • Loading branch information
martonka committed Oct 25, 2024
1 parent 2075ae8 commit bdd0d1b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/demangle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1351,6 +1351,9 @@ bool Demangle(const char* mangled, char* out, size_t out_size) {
}

std::copy_n(unmangled.get(), std::min(n, out_size), out);
if(n > out_size) {
out[out_size-1] = '\0';
}
return status == 0;
#else
State state;
Expand Down

0 comments on commit bdd0d1b

Please sign in to comment.