Merge "Fix potential divide by zero."
diff --git a/scripts/native_heapdump_viewer.py b/scripts/native_heapdump_viewer.py
index 8cda6b6..d896ca6 100755
--- a/scripts/native_heapdump_viewer.py
+++ b/scripts/native_heapdump_viewer.py
@@ -225,7 +225,13 @@
 
 def display(indent, total, parent_total, node):
     fd = addr2line(node.addr)
-    print "%9d %6.2f%% %6.2f%% %8d %s%s %s %s %s" % (node.size, 100*node.size/float(total), 100*node.size/float(parent_total), node.number, indent, node.addr, fd.library, fd.function, fd.location)
+    total_percent = 0
+    if total != 0:
+      total_percent = 100 * node.size / float(total)
+    parent_percent = 0
+    if parent_total != 0:
+      parent_percent = 100 * node.size / float(parent_total)
+    print "%9d %6.2f%% %6.2f%% %8d %s%s %s %s %s" % (node.size, total_percent, parent_percent, node.number, indent, node.addr, fd.library, fd.function, fd.location)
     children = sorted(node.children.values(), key=lambda x: x.size, reverse=True)
     for child in children:
         display(indent + "  ", total, node.size, child)