From 39498beffda87ff2f2ad6137b62e33323e03f5d3 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 18 Jul 2014 00:09:05 +0900 Subject: [PATCH] examples: Fix possible division by zero --- examples/deflate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/deflate.c b/examples/deflate.c index 697c19e8..b68f7ae9 100644 --- a/examples/deflate.c +++ b/examples/deflate.c @@ -133,7 +133,7 @@ static void deflate(nghttp2_hd_deflater *deflater, outlen = rv; printf("\nDeflate (%zu byte(s), ratio %.02f):\n\n", - outlen, (double)outlen / sum); + outlen, sum == 0 ? 0 : (double)outlen / sum); for(i = 0; i < outlen; ++i) { if((i & 0x0fu) == 0) {