guard against division by 0

valgrind + bff

Change-Id: I5fa40f7a9759c98bb70ee6eb854dd9b376401f89