core/metrics: prevent division by zero

This commit is contained in:
Bernhard Miklautz 2015-06-19 17:21:16 +02:00
parent c8731eaa2c
commit 41ef7ca17c

View File

@ -30,7 +30,9 @@ double metrics_write_bytes(rdpMetrics* metrics, UINT32 UncompressedBytes, UINT32
metrics->TotalUncompressedBytes += UncompressedBytes; metrics->TotalUncompressedBytes += UncompressedBytes;
metrics->TotalCompressedBytes += CompressedBytes; metrics->TotalCompressedBytes += CompressedBytes;
if (UncompressedBytes != 0)
CompressionRatio = ((double) CompressedBytes) / ((double) UncompressedBytes); CompressionRatio = ((double) CompressedBytes) / ((double) UncompressedBytes);
if (metrics->TotalUncompressedBytes != 0)
metrics->TotalCompressionRatio = ((double) metrics->TotalCompressedBytes) / ((double) metrics->TotalUncompressedBytes); metrics->TotalCompressionRatio = ((double) metrics->TotalCompressedBytes) / ((double) metrics->TotalUncompressedBytes);
return CompressionRatio; return CompressionRatio;