pcsx2:cso: NULL pointer check

Coverity:

CID 146846 (#1 of 1): Dereference after null check (FORWARD_NULL)
5. var_deref_model: Passing null pointer fp to fclose, which dereferences it
This commit is contained in:
Gregory Hainaut 2015-09-21 20:43:08 +02:00
parent b9e00ab611
commit 4184d6eef5
1 changed files with 5 additions and 3 deletions

View File

@ -43,11 +43,13 @@ bool CsoFileReader::CanHandle(const wxString& fileName) {
if (wxFileName::FileExists(fileName) && fileName.Lower().EndsWith(L".cso")) {
FILE* fp = PX_fopen_rb(fileName);
CsoHeader hdr;
if (fp && fread(&hdr, 1, sizeof(hdr), fp) == sizeof(hdr)) {
if (fp) {
if (fread(&hdr, 1, sizeof(hdr), fp) == sizeof(hdr)) {
supported = ValidateHeader(hdr);
}
fclose(fp);
}
}
return supported;
}