From 41ef7ca17c780d353338a2ff62e4008d79a015f8 Mon Sep 17 00:00:00 2001 From: Bernhard Miklautz Date: Fri, 19 Jun 2015 17:21:16 +0200 Subject: [PATCH] core/metrics: prevent division by zero --- libfreerdp/core/metrics.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libfreerdp/core/metrics.c b/libfreerdp/core/metrics.c index bfcfd445e..cca4e16ac 100644 --- a/libfreerdp/core/metrics.c +++ b/libfreerdp/core/metrics.c @@ -30,8 +30,10 @@ double metrics_write_bytes(rdpMetrics* metrics, UINT32 UncompressedBytes, UINT32 metrics->TotalUncompressedBytes += UncompressedBytes; metrics->TotalCompressedBytes += CompressedBytes; - CompressionRatio = ((double) CompressedBytes) / ((double) UncompressedBytes); - metrics->TotalCompressionRatio = ((double) metrics->TotalCompressedBytes) / ((double) metrics->TotalUncompressedBytes); + if (UncompressedBytes != 0) + CompressionRatio = ((double) CompressedBytes) / ((double) UncompressedBytes); + if (metrics->TotalUncompressedBytes != 0) + metrics->TotalCompressionRatio = ((double) metrics->TotalCompressedBytes) / ((double) metrics->TotalUncompressedBytes); return CompressionRatio; }