Fix dereference after null check, CID 1570976

This commit is contained in:
olszomal 2023-11-13 14:54:59 +01:00 committed by Michał Trojnara
parent 6d6270094e
commit 6f4e9ab597

View File

@ -3653,10 +3653,12 @@ static int use_legacy(void)
static int file_exists(const char *filename)
{
FILE *file = fopen(filename, "rb");
if (file) {
fclose(file);
return 1; /* File exists */
if (filename) {
FILE *file = fopen(filename, "rb");
if (file) {
fclose(file);
return 1; /* File exists */
}
}
return 0; /* File does not exist */
}