mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-29 17:53:09 +03:00
Prevent overflow of disc cache hysteresis.
The default disc cache size is 1GB (1024 * 1024 * 1024). On systems with 32bit size_t, the hysteresis calculation, which multiplied 1GB by 20 would overflow, causing a zero hysteresis. (1024 * 1024 * 1024) * 20 % (2^32) = 0 Thanks to Jonas Amoson for reporting.
This commit is contained in:
parent
98496cdae1
commit
da2aa05b73
@ -155,10 +155,10 @@ nserror netsurf_init(const char *store_path)
|
|||||||
hlcache_parameters.llcache.fetch_attempts = nsoption_uint(max_retried_fetches);
|
hlcache_parameters.llcache.fetch_attempts = nsoption_uint(max_retried_fetches);
|
||||||
|
|
||||||
/* image cache is 25% of total memory cache size */
|
/* image cache is 25% of total memory cache size */
|
||||||
image_cache_parameters.limit = (hlcache_parameters.llcache.limit * 25) / 100;
|
image_cache_parameters.limit = hlcache_parameters.llcache.limit / 4;
|
||||||
|
|
||||||
/* image cache hysteresis is 20% of the image cache size */
|
/* image cache hysteresis is 20% of the image cache size */
|
||||||
image_cache_parameters.hysteresis = (image_cache_parameters.limit * 20) / 100;
|
image_cache_parameters.hysteresis = image_cache_parameters.limit / 5;
|
||||||
|
|
||||||
/* account for image cache use from total */
|
/* account for image cache use from total */
|
||||||
hlcache_parameters.llcache.limit -= image_cache_parameters.limit;
|
hlcache_parameters.llcache.limit -= image_cache_parameters.limit;
|
||||||
@ -167,7 +167,7 @@ nserror netsurf_init(const char *store_path)
|
|||||||
hlcache_parameters.llcache.store.limit = nsoption_uint(disc_cache_size);
|
hlcache_parameters.llcache.store.limit = nsoption_uint(disc_cache_size);
|
||||||
|
|
||||||
/* set backing store hysterissi to 20% */
|
/* set backing store hysterissi to 20% */
|
||||||
hlcache_parameters.llcache.store.hysteresis = (hlcache_parameters.llcache.store.limit * 20) / 100;;
|
hlcache_parameters.llcache.store.hysteresis = hlcache_parameters.llcache.store.limit / 5;
|
||||||
|
|
||||||
/* set the path to the backing store */
|
/* set the path to the backing store */
|
||||||
hlcache_parameters.llcache.store.path =
|
hlcache_parameters.llcache.store.path =
|
||||||
|
Loading…
Reference in New Issue
Block a user