Fix a possible crash if a file fails to be closed

Change-Id: I6bc806a68b81ea5bde09bada1175f257c296afcd
This commit is contained in:
KongQun Yang 2015-11-12 15:56:23 -08:00
parent 29e14a3d6b
commit d60cc9416f
1 changed files with 6 additions and 3 deletions

View File

@ -17,9 +17,12 @@ namespace media {
/// scope.
struct FileCloser {
inline void operator()(File* file) const {
if (file != NULL && !file->Close()) {
LOG(WARNING) << "Failed to close the file properly: "
<< file->file_name();
if (file != NULL) {
const std::string filename = file->file_name();
if (!file->Close()) {
LOG(WARNING) << "Failed to close the file properly: "
<< filename;
}
}
}
};