summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2016-12-08 22:26:03 +0000
committerVitaly Buka <vitalybuka@google.com>2016-12-08 22:26:03 +0000
commit5d16b9b8ddb23d7ed4a09a48f52eceb2c76f83cb (patch)
treee186a1f29f0a2d32fd73b6d864e8f5dff55d86f9
parentd1033f575617298c2d4c4c629a5fe10bc2120e4f (diff)
downloadbcm5719-llvm-5d16b9b8ddb23d7ed4a09a48f52eceb2c76f83cb.tar.gz
bcm5719-llvm-5d16b9b8ddb23d7ed4a09a48f52eceb2c76f83cb.zip
[sanitizer] Add workaround for empty strings
Summary: I see crashes on this check when some reports are being generated. Reviewers: eugenis Subscribers: kubabrecka, llvm-commits Differential Revision: https://reviews.llvm.org/D27574 llvm-svn: 289145
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc32
1 files changed, 14 insertions, 18 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc
index 36b4fa91f54..31506fe5c83 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc
@@ -242,25 +242,21 @@ static const char *ParseFileLineInfo(AddressInfo *info, const char *str) {
char *file_line_info = 0;
str = ExtractToken(str, "\n", &file_line_info);
CHECK(file_line_info);
- // Parse the last :<int>, which must be there.
- char *last_colon = internal_strrchr(file_line_info, ':');
- CHECK(last_colon);
- int line_or_column = internal_atoll(last_colon + 1);
- // Truncate the string at the last colon and find the next-to-last colon.
- *last_colon = '\0';
- last_colon = internal_strrchr(file_line_info, ':');
- if (last_colon && IsDigit(last_colon[1])) {
- // If the second-to-last colon is followed by a digit, it must be the line
- // number, and the previous parsed number was a column.
- info->line = internal_atoll(last_colon + 1);
- info->column = line_or_column;
- *last_colon = '\0';
- } else {
- // Otherwise, we have line info but no column info.
- info->line = line_or_column;
- info->column = 0;
+
+ if (uptr size = internal_strlen(file_line_info)) {
+ char *back = file_line_info + size - 1;
+ for (int i = 0; i < 2; ++i) {
+ while (back > file_line_info && IsDigit(*back)) --back;
+ if (*back != ':' || !IsDigit(back[1])) break;
+ info->column = info->line;
+ info->line = internal_atoll(back + 1);
+ // Truncate the string at the colon to keep only filename.
+ *back = '\0';
+ --back;
+ }
+ ExtractToken(file_line_info, "", &info->file);
}
- ExtractToken(file_line_info, "", &info->file);
+
InternalFree(file_line_info);
return str;
}
OpenPOWER on IntegriCloud