From 789d3746506eebb699258f97de1923834edbfa3c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 27 Jun 2019 16:12:26 +0200 Subject: [PATCH] Fix line numbers in stack traces under macOS The last digit was truncated as the code discarded the trailing "\n" which wasn't really there, as ReadLine() helper function already removed it, and so ended up removing the last digit of the line number, resulting in mostly plausibly looking but completely wrong line information in the assert dialog. --- src/unix/stackwalk.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/unix/stackwalk.cpp b/src/unix/stackwalk.cpp index c30c44d762..2d8e5097f1 100644 --- a/src/unix/stackwalk.cpp +++ b/src/unix/stackwalk.cpp @@ -286,18 +286,18 @@ int wxStackWalker::InitFrames(wxStackFrame *arr, size_t n, void **addresses, cha // func(args) (in module) (file:line) // // or just the same address back if it couldn't be resolved. - const size_t posIn = buffer.find("(in "); + const size_t posIn = buffer.find(" (in "); if ( posIn != wxString::npos ) { name.assign(buffer, 0, posIn); - size_t posAt = buffer.find(") (", posIn + 3); + size_t posAt = buffer.find(") (", posIn + 5); // Skip " (in " if ( posAt != wxString::npos ) { posAt += 3; // Skip ") (" - // Discard the two last characters which are ")\n" - wxString location(buffer, posAt, buffer.length() - posAt - 2); + // Discard the last character which is ")" + wxString location(buffer, posAt, buffer.length() - posAt - 1); wxString linenum; filename = location.BeforeFirst(':', &linenum);