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

Side by Side Diff: url/url_canon_icu.cc

Issue 881073002: Update url_canon_icu prevent crash with GoogleUrl. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove the DCHECK so that debug and release builds behave the same. Created 5 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 // ICU integration functions. 5 // ICU integration functions.
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 // On error, this will return false. The output in this case is undefined. 156 // On error, this will return false. The output in this case is undefined.
157 // TODO(jungshik): use UTF-8/ASCII version of nameToASCII. 157 // TODO(jungshik): use UTF-8/ASCII version of nameToASCII.
158 // Change the function signature and callers accordingly to avoid unnecessary 158 // Change the function signature and callers accordingly to avoid unnecessary
159 // conversions in our code. In addition, consider using icu::IDNA's UTF-8/ASCII 159 // conversions in our code. In addition, consider using icu::IDNA's UTF-8/ASCII
160 // version with StringByteSink. That way, we can avoid C wrappers and additional 160 // version with StringByteSink. That way, we can avoid C wrappers and additional
161 // string conversion. 161 // string conversion.
162 bool IDNToASCII(const base::char16* src, int src_len, CanonOutputW* output) { 162 bool IDNToASCII(const base::char16* src, int src_len, CanonOutputW* output) {
163 DCHECK(output->length() == 0); // Output buffer is assumed empty. 163 DCHECK(output->length() == 0); // Output buffer is assumed empty.
164 164
165 UIDNA* uidna = g_uidna.Get().value; 165 UIDNA* uidna = g_uidna.Get().value;
166 DCHECK(uidna != NULL); 166 if (uidna == NULL) {
167 return false; // Prevent null-deref in uidna_nameToASCII.
168 }
jungshik at Google 2015/03/27 21:59:16 This should not happen. If it happens, we have to
167 while (true) { 169 while (true) {
168 UErrorCode err = U_ZERO_ERROR; 170 UErrorCode err = U_ZERO_ERROR;
169 UIDNAInfo info = UIDNA_INFO_INITIALIZER; 171 UIDNAInfo info = UIDNA_INFO_INITIALIZER;
170 int output_length = uidna_nameToASCII(uidna, src, src_len, output->data(), 172 int output_length = uidna_nameToASCII(uidna, src, src_len, output->data(),
171 output->capacity(), &info, &err); 173 output->capacity(), &info, &err);
172 if (U_SUCCESS(err) && info.errors == 0) { 174 if (U_SUCCESS(err) && info.errors == 0) {
173 output->set_length(output_length); 175 output->set_length(output_length);
174 return true; 176 return true;
175 } 177 }
176 178
177 // TODO(jungshik): Look at info.errors to handle them case-by-case basis 179 // TODO(jungshik): Look at info.errors to handle them case-by-case basis
178 // if necessary. 180 // if necessary.
179 if (err != U_BUFFER_OVERFLOW_ERROR || info.errors != 0) 181 if (err != U_BUFFER_OVERFLOW_ERROR || info.errors != 0)
180 return false; // Unknown error, give up. 182 return false; // Unknown error, give up.
181 183
182 // Not enough room in our buffer, expand. 184 // Not enough room in our buffer, expand.
183 output->Resize(output_length); 185 output->Resize(output_length);
184 } 186 }
185 } 187 }
186 188
187 } // namespace url 189 } // namespace url
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698