diff options
-rw-r--r-- | base/file_util_proxy.cc | 8 | ||||
-rw-r--r-- | base/file_util_proxy.h | 3 | ||||
-rw-r--r-- | chrome/browser/nacl_host/nacl_process_host.cc | 1 |
3 files changed, 9 insertions, 3 deletions
diff --git a/base/file_util_proxy.cc b/base/file_util_proxy.cc index 0e4badf..7757c42 100644 --- a/base/file_util_proxy.cc +++ b/base/file_util_proxy.cc @@ -854,8 +854,10 @@ bool FileUtilProxy::Read( int64 offset, int bytes_to_read, ReadCallback* callback) { - if (bytes_to_read < 0) + if (bytes_to_read < 0) { + delete callback; return false; + } return Start(FROM_HERE, message_loop_proxy, new RelayRead(file, offset, bytes_to_read, callback)); } @@ -868,8 +870,10 @@ bool FileUtilProxy::Write( const char* buffer, int bytes_to_write, WriteCallback* callback) { - if (bytes_to_write <= 0) + if (bytes_to_write <= 0) { + delete callback; return false; + } return Start(FROM_HERE, message_loop_proxy, new RelayWrite(file, offset, buffer, bytes_to_write, callback)); } diff --git a/base/file_util_proxy.h b/base/file_util_proxy.h index 872da44..30f051b 100644 --- a/base/file_util_proxy.h +++ b/base/file_util_proxy.h @@ -34,6 +34,8 @@ class BASE_EXPORT FileUtilProxy { // This callback is used by methods that report only an error code. It is // valid to pass NULL as the callback parameter to any function that takes a // StatusCallback, in which case the operation will complete silently. + // The ownership of |callback| is taken by the function and will always be + // deleted by the function even on failure. typedef Callback1<PlatformFileError /* error code */>::Type StatusCallback; typedef Callback3<PlatformFileError /* error code */, @@ -60,6 +62,7 @@ class BASE_EXPORT FileUtilProxy { // If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to create // a new file at the given |file_path| and calls back with // PLATFORM_FILE_ERROR_FILE_EXISTS if the |file_path| already exists. + // Takes ownership of |callback| and will delete it even on failure. static bool CreateOrOpen(scoped_refptr<MessageLoopProxy> message_loop_proxy, const FilePath& file_path, int file_flags, diff --git a/chrome/browser/nacl_host/nacl_process_host.cc b/chrome/browser/nacl_host/nacl_process_host.cc index 2db830d2..6922128 100644 --- a/chrome/browser/nacl_host/nacl_process_host.cc +++ b/chrome/browser/nacl_host/nacl_process_host.cc @@ -242,7 +242,6 @@ void NaClProcessHost::OnProcessLaunched() { irt_path, base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, callback)) { - delete callback; delete this; } } |