From d60cc9416f92dc9dd4e59ecc9883b77ad7acfb3f Mon Sep 17 00:00:00 2001 From: KongQun Yang Date: Thu, 12 Nov 2015 15:56:23 -0800 Subject: [PATCH] Fix a possible crash if a file fails to be closed Change-Id: I6bc806a68b81ea5bde09bada1175f257c296afcd --- packager/media/file/file_closer.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packager/media/file/file_closer.h b/packager/media/file/file_closer.h index e0d1305a8c..550c2fda5a 100644 --- a/packager/media/file/file_closer.h +++ b/packager/media/file/file_closer.h @@ -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; + } } } };