[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] [patch #8274] Avoid potential division by zero in movie_r
From: |
Petter Reinholdtsen |
Subject: |
[Gnash-commit] [patch #8274] Avoid potential division by zero in movie_root::processInvoke() |
Date: |
Tue, 14 Jan 2014 14:20:50 +0000 |
User-agent: |
Opera/9.80 (X11; Linux x86_64) Presto/2.12.388 Version/12.16 |
URL:
<http://savannah.gnu.org/patch/?8274>
Summary: Avoid potential division by zero in
movie_root::processInvoke()
Project: Gnash - The GNU Flash player
Submitted by: pere
Submitted on: Tue 14 Jan 2014 14:20:50 GMT
Category: core
Priority: 5 - Normal
Status: None
Privacy: Public
Assigned to: None
Originator Email:
Open/Closed: Open
Discussion Lock: Any
_______________________________________________________
Details:
I had a quick look at the new Coverity scan result, and decided to try
to address CID 1149142, which report a potential division by zero.
This patch should solve the problem, by only dividing if total is higher than
zero.
diff --git a/libcore/movie_root.cpp b/libcore/movie_root.cpp
index 1bae796..3ec506c 100644
--- a/libcore/movie_root.cpp
+++ b/libcore/movie_root.cpp
@@ -1626,7 +1626,11 @@ movie_root::processInvoke(ExternalInterface::invoke_t
*invoke)
MovieClip *mc = getLevel(0);
int loaded = mc->get_bytes_loaded();
int total = mc->get_bytes_total();
- as_value val((loaded/total) * 100);
+ int percent = 0;
+ if (total > 0) { /* avoid division by zero */
+ percent = 100 * loaded / total;
+ }
+ as_value val(percent);
// PercentLoaded sends the percentage
ss << ExternalInterface::toXML(val);
} else if (invoke->name == "Play") {
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/patch/?8274>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Gnash-commit] [patch #8274] Avoid potential division by zero in movie_root::processInvoke(),
Petter Reinholdtsen <=