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

Side by Side Diff: webkit/glue/ftp_directory_listing_response_delegate.cc

Issue 355037: Coverity: Fix leaking UCharsetDetector in ftp code. (Closed)
Patch Set: Created 11 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « net/ftp/ftp_directory_listing_buffer_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/glue/ftp_directory_listing_response_delegate.h" 5 #include "webkit/glue/ftp_directory_listing_response_delegate.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/i18n/icu_string_conversions.h" 9 #include "base/i18n/icu_string_conversions.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 20 matching lines...) Expand all
31 // can be other use cases. 31 // can be other use cases.
32 std::string DetectEncoding(const std::string& text) { 32 std::string DetectEncoding(const std::string& text) {
33 if (IsStringASCII(text)) 33 if (IsStringASCII(text))
34 return std::string(); 34 return std::string();
35 UErrorCode status = U_ZERO_ERROR; 35 UErrorCode status = U_ZERO_ERROR;
36 UCharsetDetector* detector = ucsdet_open(&status); 36 UCharsetDetector* detector = ucsdet_open(&status);
37 ucsdet_setText(detector, text.data(), static_cast<int32_t>(text.length()), 37 ucsdet_setText(detector, text.data(), static_cast<int32_t>(text.length()),
38 &status); 38 &status);
39 const UCharsetMatch* match = ucsdet_detect(detector, &status); 39 const UCharsetMatch* match = ucsdet_detect(detector, &status);
40 const char* encoding = ucsdet_getName(match, &status); 40 const char* encoding = ucsdet_getName(match, &status);
41 ucsdet_close(detector);
41 // Should we check the quality of the match? A rather arbitrary number is 42 // Should we check the quality of the match? A rather arbitrary number is
42 // assigned by ICU and it's hard to come up with a lower limit. 43 // assigned by ICU and it's hard to come up with a lower limit.
43 if (U_FAILURE(status)) 44 if (U_FAILURE(status))
44 return std::string(); 45 return std::string();
45 return encoding; 46 return encoding;
46 } 47 }
47 48
48 string16 RawByteSequenceToFilename(const char* raw_filename, 49 string16 RawByteSequenceToFilename(const char* raw_filename,
49 const std::string& encoding) { 50 const std::string& encoding) {
50 if (encoding.empty()) 51 if (encoding.empty())
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 250
250 void FtpDirectoryListingResponseDelegate::SendResponseBufferToClient() { 251 void FtpDirectoryListingResponseDelegate::SendResponseBufferToClient() {
251 if (!response_buffer_.empty()) { 252 if (!response_buffer_.empty()) {
252 client_->didReceiveData(loader_, response_buffer_.data(), 253 client_->didReceiveData(loader_, response_buffer_.data(),
253 response_buffer_.length()); 254 response_buffer_.length());
254 response_buffer_.clear(); 255 response_buffer_.clear();
255 } 256 }
256 } 257 }
257 258
258 } // namespace webkit_glue 259 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « net/ftp/ftp_directory_listing_buffer_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698