Skip to content

Commit 7371085

Browse files
committed
ubsan: fix few format string bugs
This fixes just a few of the warnings. Ubsan is not completely clean yet, but these somehow pop up while I was fixing other sanitizers. Depends on D107983. Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D107984
1 parent c90bf3f commit 7371085

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎compiler-rt/lib/ubsan/ubsan_diag.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ static void RenderLocation(InternalScopedString *Buffer, Location Loc) {
157157
return;
158158
}
159159
case Location::LK_Memory:
160-
Buffer->append("%p", Loc.getMemoryLocation());
160+
Buffer->append("%p", reinterpret_cast<void *>(Loc.getMemoryLocation()));
161161
return;
162162
case Location::LK_Symbolized: {
163163
const AddressInfo &Info = Loc.getSymbolizedStack()->info;
@@ -169,7 +169,7 @@ static void RenderLocation(InternalScopedString *Buffer, Location Loc) {
169169
RenderModuleLocation(Buffer, Info.module, Info.module_offset,
170170
Info.module_arch, common_flags()->strip_path_prefix);
171171
else
172-
Buffer->append("%p", Info.address);
172+
Buffer->append("%p", reinterpret_cast<void *>(Info.address));
173173
return;
174174
}
175175
case Location::LK_Null:
@@ -286,7 +286,7 @@ static void PrintMemorySnippet(const Decorator &Decor, MemoryLocation Loc,
286286
Buffer.append("\n");
287287

288288
// Emit highlights.
289-
Buffer.append(Decor.Highlight());
289+
Buffer.append("%s", Decor.Highlight());
290290
Range *InRange = upperBound(Min, Ranges, NumRanges);
291291
for (uptr P = Min; P != Max; ++P) {
292292
char Pad = ' ', Byte = ' ';
@@ -355,7 +355,7 @@ Diag::~Diag() {
355355
Buffer.clear();
356356
}
357357

358-
Buffer.append(Decor.Bold());
358+
Buffer.append("%s", Decor.Bold());
359359
RenderLocation(&Buffer, Loc);
360360
Buffer.append(":");
361361

0 commit comments

Comments
 (0)