[vlc-commits] update: avoid division by zero

Rémi Denis-Courmont git at videolan.org
Mon Aug 31 19:13:09 CEST 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Aug 31 20:11:52 2015 +0300| [145b05739d2dc9607ead4ef8244ba2172d97b389] | committer: Rémi Denis-Courmont

update: avoid division by zero

If the downloaded file is empty or of unknown size.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=145b05739d2dc9607ead4ef8244ba2172d97b389
---

 src/misc/update.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/misc/update.c b/src/misc/update.c
index 58fbabb..ca2ba67 100644
--- a/src/misc/update.c
+++ b/src/misc/update.c
@@ -471,7 +471,7 @@ bool update_NeedUpgrade( update_t *p_update )
  * \param l_size the size in bytes
  * \return the size as a string
  */
-static char *size_str( long int l_size )
+static char *size_str( uint64_t l_size )
 {
     char *psz_tmp = NULL;
     int i_retval = 0;
@@ -526,8 +526,8 @@ static void* update_DownloadReal( void *obj )
 {
     update_download_thread_t *p_udt = (update_download_thread_t *)obj;
     dialog_progress_bar_t *p_progress = NULL;
-    long int l_size;
-    long int l_downloaded = 0;
+    uint64_t l_size;
+    uint64_t l_downloaded = 0;
     float f_progress;
     char *psz_status;
     char *psz_downloaded = NULL;
@@ -556,7 +556,8 @@ static void* update_DownloadReal( void *obj )
     }
 
     /* Get the stream size */
-    l_size = stream_Size( p_stream );
+    if( stream_GetSize( p_stream, &l_size ) || l_size == 0 )
+        goto end;
 
     /* Get the file name and open it*/
     psz_tmpdestfile = strrchr( p_update->release.psz_url, '/' );



More information about the vlc-commits mailing list