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

Side by Side Diff: ui/base/resource/data_pack.cc

Issue 2117693002: Fix crash issues if there is no resources pack in content shell Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | « services/catalog/reader.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/base/resource/data_pack.h" 5 #include "ui/base/resource/data_pack.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // bothering to do right now. 183 // bothering to do right now.
184 #if defined(__BYTE_ORDER) 184 #if defined(__BYTE_ORDER)
185 // Linux check 185 // Linux check
186 static_assert(__BYTE_ORDER == __LITTLE_ENDIAN, 186 static_assert(__BYTE_ORDER == __LITTLE_ENDIAN,
187 "datapack assumes little endian"); 187 "datapack assumes little endian");
188 #elif defined(__BIG_ENDIAN__) 188 #elif defined(__BIG_ENDIAN__)
189 // Mac check 189 // Mac check
190 #error DataPack assumes little endian 190 #error DataPack assumes little endian
191 #endif 191 #endif
192 192
193 if (!mmap_)
194 return false;
195
193 const DataPackEntry* target = reinterpret_cast<const DataPackEntry*>( 196 const DataPackEntry* target = reinterpret_cast<const DataPackEntry*>(
194 bsearch(&resource_id, mmap_->data() + kHeaderLength, resource_count_, 197 bsearch(&resource_id, mmap_->data() + kHeaderLength, resource_count_,
195 sizeof(DataPackEntry), DataPackEntry::CompareById)); 198 sizeof(DataPackEntry), DataPackEntry::CompareById));
196 if (!target) { 199 if (!target) {
197 return false; 200 return false;
198 } 201 }
199 202
200 const DataPackEntry* next_entry = target + 1; 203 const DataPackEntry* next_entry = target + 1;
201 // If the next entry points beyond the end of the file this data pack's entry 204 // If the next entry points beyond the end of the file this data pack's entry
202 // table is corrupt. Log an error and return false. See 205 // table is corrupt. Log an error and return false. See
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 return false; 348 return false;
346 } 349 }
347 } 350 }
348 351
349 base::CloseFile(file); 352 base::CloseFile(file);
350 353
351 return true; 354 return true;
352 } 355 }
353 356
354 } // namespace ui 357 } // namespace ui
OLDNEW
« no previous file with comments | « services/catalog/reader.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698