Merge pull request #2713 from bmiklautz/divbyzero

core/metrics: prevent division by zero
This commit is contained in:
Marc-André Moreau 2015-06-22 08:53:36 -04:00
commit 9aabec73f5

View File

@ -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;
}