image-source: Fix reloading bug when stat fails
(Note: This commit also modified text-freetype2) The implementation of get_modified_timestamp() did not check the return value of stat(), so in case the check fails the values in the stats structure can be any garbage on the stack and the value of stats.st_mtime can change on every call. This can trigger a reload of the image every second, even if the file was not actually modified. Closes jp9000/obs-studio#520
This commit is contained in:
parent
a2b6432f53
commit
18a2b61b85
@ -30,7 +30,8 @@ struct image_source {
|
|||||||
static time_t get_modified_timestamp(const char *filename)
|
static time_t get_modified_timestamp(const char *filename)
|
||||||
{
|
{
|
||||||
struct stat stats;
|
struct stat stats;
|
||||||
stat(filename, &stats);
|
if (stat(filename, &stats) != 0)
|
||||||
|
return -1;
|
||||||
return stats.st_mtime;
|
return stats.st_mtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,7 +322,8 @@ time_t get_modified_timestamp(char *filename)
|
|||||||
|
|
||||||
// stat is apparently terrifying and horrible, but we only call it once
|
// stat is apparently terrifying and horrible, but we only call it once
|
||||||
// every second at most.
|
// every second at most.
|
||||||
stat(filename, &stats);
|
if (stat(filename, &stats) != 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
return stats.st_mtime;
|
return stats.st_mtime;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user