diff --git a/libwvdrmengine/cdm/core/src/device_files.cpp b/libwvdrmengine/cdm/core/src/device_files.cpp index 92869026..0bee6012 100644 --- a/libwvdrmengine/cdm/core/src/device_files.cpp +++ b/libwvdrmengine/cdm/core/src/device_files.cpp @@ -603,6 +603,9 @@ bool DeviceFiles::RetrieveFile(const char* name, std::string* serialized_file) { ssize_t bytes = file_->FileSize(path); if (bytes <= 0) { LOGW("DeviceFiles::RetrieveFile: File size invalid: %s", path.c_str()); + // Remove the corrupted file so the caller will not get the same error + // when trying to access the file repeatedly, causing the system to stall. + file_->Remove(path); return false; } @@ -637,6 +640,9 @@ bool DeviceFiles::RetrieveFile(const char* name, std::string* serialized_file) { if (hash.compare(hash_file.hash())) { LOGW("DeviceFiles::RetrieveFile: Hash mismatch"); + // Remove the corrupted file so the caller will not get the same error + // when trying to access the file repeatedly, causing the system to stall. + file_->Remove(path); return false; }