Make VG_(percentify)() cope if the denominator is zero.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4149 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/m_libcprint.c b/coregrind/m_libcprint.c
index 3a3bc15..e5f32d9 100644
--- a/coregrind/m_libcprint.c
+++ b/coregrind/m_libcprint.c
@@ -158,8 +158,14 @@
void VG_(percentify)(UInt n, UInt m, UInt d, Int n_buf, char buf[])
{
Int i, len, space;
+ ULong p1;
- ULong p1 = (100*n) / m;
+ if (m == 0) {
+ VG_(sprintf)(buf, "--%%");
+ return;
+ }
+
+ p1 = (100*n) / m;
if (d == 0) {
VG_(sprintf)(buf, "%lld%%", p1);