Skip to content

Commit 5eb1e10

Browse files
committed
Handle 0 safely
If the input number is 0, the result of log10 is unrepresentable as an integer, which is UB.
1 parent 4501abc commit 5eb1e10

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

llvm/tools/llvm-objdump/DXContainerDump.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ static void printColumnHeaders(raw_ostream &OS, ArrayRef<size_t> Lengths) {
5454
}
5555

5656
static size_t digitsForNumber(size_t N) {
57+
if (N == 0)
58+
return 1;
5759
return static_cast<size_t>(log10(static_cast<double>(N))) + 1;
5860
}
5961

0 commit comments

Comments
 (0)