| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |