[PATCH] abg-dwarf-reader.cc: Avoid division by zero.
Giuliano Procida
gprocida@google.com
Mon Mar 30 16:40:41 GMT 2020
The DWARF reader could divide by zero when emitting statistics about
late canonicalisation of types. This is undefined behaviour but
typically results in process termination.
* src/abg-dwarf-reader.cc (perform_late_type_canonicalizing):
If total is zero, don't try to output percentages using it as
a divisor.
Signed-off-by: Giuliano Procida <gprocida@google.com>
---
src/abg-dwarf-reader.cc | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc
index 10ca1232..249e196d 100644
--- a/src/abg-dwarf-reader.cc
+++ b/src/abg-dwarf-reader.cc
@@ -5849,11 +5849,15 @@ public:
<< elf_path()
<< "\n";
cerr << " # late canonicalized types: "
- << num_canonicalized
- << " (" << num_canonicalized * 100 / total << "%)\n"
+ << num_canonicalized;
+ if (total)
+ cerr << " (" << num_canonicalized * 100 / total << "%)";
+ cerr << "\n"
<< " # missed canonicalization opportunities: "
- << num_missed
- << " (" << num_missed * 100 / total << "%)\n";
+ << num_missed;
+ if (total)
+ cerr << " (" << num_missed * 100 / total << "%)";
+ cerr << "\n";
}
}
--
2.26.0.rc2.310.g2932bb562d-goog
More information about the Libabigail
mailing list