Index: lib/asan/asan_errors.h =================================================================== --- lib/asan/asan_errors.h +++ lib/asan/asan_errors.h @@ -229,6 +229,25 @@ void Print(); }; +struct ErrorStringFunctionSizeOverflow : ErrorBase { + u32 tid; + // ErrorStringFunctionSizeOverflow doesn't own the stack trace. + BufferedStackTrace *stack; + AddressDescriptionBase addr_description; + uptr size; + // VS2013 doesn't implement unrestricted unions, so we need a trivial default + // constructor + ErrorStringFunctionSizeOverflow() = default; + ErrorStringFunctionSizeOverflow(u32 tid_, BufferedStackTrace *stack_, + uptr addr, uptr size_) + : tid(tid_), stack(stack_), size(size_) { + scariness.Clear(); + scariness.Scare(10, "negative-size-param"); + addr_description = AddressDescription(addr); + } + void Print(); +}; + #define FOR_EACH_ERROR_KIND_MEMBER_NAME_PAIR(macro) \ macro(StackOverflow, stack_overflow) \ macro(DeadlySignal, deadly_signal) \ @@ -240,7 +259,8 @@ macro(SanitizerGetAllocatedSizeNotOwned, \ sanitizer_get_allocated_size_not_owned) \ macro(StringFunctionMemoryRangesOverlap, \ - string_function_memory_ranges_overlap) + string_function_memory_ranges_overlap) \ + macro(StringFunctionSizeOverflow, string_function_size_overflow) enum ErrorKind { kErrorKindInvalid = 0, Index: lib/asan/asan_errors.cc =================================================================== --- lib/asan/asan_errors.cc +++ lib/asan/asan_errors.cc @@ -209,4 +209,16 @@ ReportErrorSummary(bug_type, stack); } +void ErrorStringFunctionSizeOverflow::Print() { + Decorator d; + Printf("%s", d.Warning()); + const char *bug_type = "negative-size-param"; + Report("ERROR: AddressSanitizer: %s: (size=%zd)\n", bug_type, size); + Printf("%s", d.EndWarning()); + scariness.Print(); + stack->Print(); + addr_description.Print(); + ReportErrorSummary(bug_type, stack); +} + } // namespace __asan Index: lib/asan/asan_report.cc =================================================================== --- lib/asan/asan_report.cc +++ lib/asan/asan_report.cc @@ -391,15 +391,9 @@ void ReportStringFunctionSizeOverflow(uptr offset, uptr size, BufferedStackTrace *stack) { ScopedInErrorReport in_report; - Decorator d; - const char *bug_type = "negative-size-param"; - Printf("%s", d.Warning()); - Report("ERROR: AddressSanitizer: %s: (size=%zd)\n", bug_type, size); - Printf("%s", d.EndWarning()); - ScarinessScore::PrintSimple(10, bug_type); - stack->Print(); - PrintAddressDescription(offset, size, bug_type); - ReportErrorSummary(bug_type, stack); + ErrorStringFunctionSizeOverflow error(GetCurrentTidOrInvalid(), stack, offset, + size); + in_report.ReportError(error); } void ReportBadParamsToAnnotateContiguousContainer(uptr beg, uptr end,