]> sjero.net Git - wget/blobdiff - src/mswindows.c
[svn] * mswindows.c (ws_percenttitle): Guard against future changes by
[wget] / src / mswindows.c
index a2094900e1963eb43551dcc18c5e2dd670b3ba37..f4affdd1c0ad5dc7cc879d254c1c0e4b8dff01a0 100644 (file)
@@ -180,19 +180,24 @@ ws_changetitle (const char *url)
 void
 ws_percenttitle (double percentage_float)
 {
-  int percentage = (int) percentage_float;
+  int percentage;
 
-  /* Only update the title when the percentage has changed.  */
-  if (percentage == old_percentage)
+  if (!title_buf || !curr_url)
     return;
 
-  old_percentage = percentage;
+  percentage = (int) percentage_float;
 
+  /* Clamp percentage value.  */
+  if (percentage < 0)
+    percentage = 0;
   if (percentage > 100)
+    percentage = 100;
+
+  /* Only update the title when the percentage has changed.  */
+  if (percentage == old_percentage)
     return;
 
-  assert (title_buf != NULL);
-  assert (curr_url != NULL);
+  old_percentage = percentage;
 
   sprintf (title_buf, "Wget [%d%%] %s", percentage, curr_url);
   SetConsoleTitle (title_buf);