mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-18 20:10:29 +01:00
WRaster: Properly set file's mtime in the cache when loading an image
The library maintains a cache to not reload a file that was previously loaded. In order to still reload an image in case its file would have changed in the meantime, the cache saves the file's modification time. As reported by Coverity (CID #331576) the 'stat' function was not on the execution path the first time an image is loaded, which means the cache information is populated with junk data. This could lead to an image not being reloaded for example. Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
committed by
Carlos R. Mafra
parent
d125f80dee
commit
f2cd2c9f03
@@ -246,6 +246,11 @@ RImage *RLoadImage(RContext *context, const char *file, int index)
|
||||
int oldest_idx = 0;
|
||||
int done = 0;
|
||||
|
||||
if (stat(file, &st) != 0) {
|
||||
/* If we can't get the info, at least use a valid time to reduce risk of problems */
|
||||
st.st_mtime = oldest;
|
||||
}
|
||||
|
||||
for (i = 0; i < RImageCacheSize; i++) {
|
||||
if (!RImageCache[i].file) {
|
||||
RImageCache[i].file = malloc(strlen(file) + 1);
|
||||
|
||||
Reference in New Issue
Block a user