Index: content/browser/download/download_item_impl.cc |
diff --git a/content/browser/download/download_item_impl.cc b/content/browser/download/download_item_impl.cc |
index 753656fee29249a461a1830456242bbddf1e0d26..938f7cc2953c8d7e9995ad22b07a5a3fa0b726a0 100644 |
--- a/content/browser/download/download_item_impl.cc |
+++ b/content/browser/download/download_item_impl.cc |
@@ -414,7 +414,9 @@ void DownloadItemImpl::Cancel(bool user_cancel) { |
if (!is_save_package_download_ && download_file_) |
ReleaseDownloadFile(true); |
- if (state_ == IN_PROGRESS_INTERNAL) { |
+ // |request_handle_| may be NULL during tests. TODO(dbeam): inject a fake one |
+ // instead? |
+ if (state_ == IN_PROGRESS_INTERNAL && request_handle_) { |
// Cancel the originating URL request unless it's already been cancelled |
// by interrupt. |
request_handle_->CancelRequest(); |