diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp --- a/lldb/source/API/SBThread.cpp +++ b/lldb/source/API/SBThread.cpp @@ -325,15 +325,14 @@ StopInfoSP stop_info_sp = exe_ctx.GetThreadPtr()->GetStopInfo(); if (stop_info_sp) { - const char *stop_desc = - exe_ctx.GetThreadPtr()->GetStopDescription().c_str(); - if (stop_desc) { + std::string stop_desc = exe_ctx.GetThreadPtr()->GetStopDescription(); + if (!stop_desc.empty()) { if (dst) - return ::snprintf(dst, dst_len, "%s", stop_desc); + return ::snprintf(dst, dst_len, "%s", stop_desc.c_str()); else { // NULL dst passed in, return the length needed to contain the // description - return ::strlen(stop_desc) + 1; // Include the NULL byte for size + return stop_desc.size() + 1; // Include the NULL byte for size } } else { size_t stop_desc_len = 0; @@ -362,7 +361,7 @@ stop_desc = exe_ctx.GetProcessPtr()->GetUnixSignals()->GetSignalAsCString( stop_info_sp->GetValue()); - if (stop_desc == nullptr || stop_desc[0] == '\0') { + if (stop_desc.empty()) { static char signal_desc[] = "signal"; stop_desc = signal_desc; stop_desc_len = @@ -391,13 +390,13 @@ break; } - if (stop_desc && stop_desc[0]) { + if (!stop_desc.empty()) { if (dst) - return ::snprintf(dst, dst_len, "%s", stop_desc) + + return ::snprintf(dst, dst_len, "%s", stop_desc.c_str()) + 1; // Include the NULL byte if (stop_desc_len == 0) - stop_desc_len = ::strlen(stop_desc) + 1; // Include the NULL byte + stop_desc_len = stop_desc.size() + 1; // Include the NULL byte return stop_desc_len; }