mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-24 17:02:35 +00:00
Prevent integer div by 0 in curl progress callback
If the curl callback is called at the exact same time as the download begins, this callback would cause an integer division by zero.
This commit is contained in:
parent
715cbd5590
commit
b2aeef5777
1 changed files with 14 additions and 1 deletions
|
|
@ -1787,12 +1787,25 @@ size_t curlwrite_data(void *ptr, size_t size, size_t nmemb, FILE *stream)
|
|||
|
||||
int curlprogress_callback(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow)
|
||||
{
|
||||
time_t curtime;
|
||||
|
||||
(void)clientp;
|
||||
(void)ultotal;
|
||||
(void)ulnow; // Function prototype requires these but we won't use, so just discard
|
||||
|
||||
curtime = time(NULL);
|
||||
|
||||
curl_dlnow = dlnow;
|
||||
curl_dltotal = dltotal;
|
||||
getbytes = curl_dlnow / (time(NULL) - curl_starttime); // To-do: Make this more accurate???
|
||||
|
||||
if (curtime > curl_starttime)
|
||||
{
|
||||
getbytes = curl_dlnow / (curtime - curl_starttime); // To-do: Make this more accurate???
|
||||
}
|
||||
else
|
||||
{
|
||||
getbytes = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue