Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Unified Diff: media/cdm/ppapi/cdm_file_io_impl.cc

Issue 562063002: CdmFileIOImpl: Always SetLength(0) before WriteFile(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/cdm/ppapi/cdm_file_io_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cdm/ppapi/cdm_file_io_impl.cc
diff --git a/media/cdm/ppapi/cdm_file_io_impl.cc b/media/cdm/ppapi/cdm_file_io_impl.cc
index 726388949ec483ef1ad05191e95a212b0677d29f..4dd13bfaa5e3d7e54b631ab1317f35cc9bde8e27 100644
--- a/media/cdm/ppapi/cdm_file_io_impl.cc
+++ b/media/cdm/ppapi/cdm_file_io_impl.cc
@@ -166,7 +166,12 @@ void CdmFileIOImpl::Write(const uint8_t* data, uint32_t data_size) {
state_ = WRITING_FILE;
// Always SetLength() in case |data_size| is less than the file size.
- SetLength(data_size);
+ // Otherwise only part of the file is overwritten and the file length will
+ // remain the old length.
+ // Set length to 0 instead of |data_size| to avoid a corrupted file if
+ // |this| is destructed after SetLength() is called but before WriteFile()
+ // is called.
+ SetLength(0);
}
void CdmFileIOImpl::Close() {
« no previous file with comments | « no previous file | media/cdm/ppapi/cdm_file_io_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698