[evolution-data-server] camel: Avoid an unlikely division by zero failure
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] camel: Avoid an unlikely division by zero failure
- Date: Wed, 21 May 2014 12:44:38 +0000 (UTC)
commit f73bc5b0fda7c6063f41ffd5d3d3cb492578f9a7
Author: Philip Withnall <philip withnall collabora co uk>
Date: Mon May 19 14:39:19 2014 +0100
camel: Avoid an unlikely division by zero failure
Coverity issue: #1061270
https://bugzilla.gnome.org/show_bug.cgi?id=730376
camel/providers/local/camel-mbox-summary.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/camel/providers/local/camel-mbox-summary.c b/camel/providers/local/camel-mbox-summary.c
index 413fd08..9d390e0 100644
--- a/camel/providers/local/camel-mbox-summary.c
+++ b/camel/providers/local/camel-mbox-summary.c
@@ -518,9 +518,14 @@ summary_update (CamelLocalSummary *cls,
while (camel_mime_parser_step (mp, NULL, NULL) == CAMEL_MIME_PARSER_STATE_FROM) {
CamelMessageInfo *info;
goffset pc = camel_mime_parser_tell_start_from (mp) + 1;
+ gint progress;
- camel_operation_progress (
- cancellable, (gint) (((gfloat) pc / size) * 100));
+ /* To avoid a division by zero if the fstat()
+ * call above failed. */
+ size = MAX (size, pc);
+ progress = (size > 0) ? (gint) (((gfloat) pc / size) * 100) : 0;
+
+ camel_operation_progress (cancellable, progress);
info = camel_folder_summary_info_new_from_parser (s, mp);
camel_folder_summary_add (s, info);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]