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

Unified Diff: runtime/vm/bitmap.cc

Issue 16356009: Fix for issue 4638 in bitmap builder. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/bitmap.cc
===================================================================
--- runtime/vm/bitmap.cc (revision 23602)
+++ runtime/vm/bitmap.cc (working copy)
@@ -32,7 +32,9 @@
bool BitmapBuilder::Get(intptr_t bit_offset) const {
- ASSERT(InRange(bit_offset));
+ if (!InRange(bit_offset)) {
+ return false;
+ }
intptr_t byte_offset = bit_offset >> kBitsPerByteLog2;
// Bits not covered by the backing store are implicitly false.
return (byte_offset < data_size_in_bytes_) && GetBit(bit_offset);
@@ -47,6 +49,10 @@
if (!value) return;
// Grow the backing store if necessary.
intptr_t byte_offset = bit_offset >> kBitsPerByteLog2;
+ if (byte_offset > kSmiMax) {
+ FATAL1("Fatal error in BitmapBuilder::Set : invalid bit_offset, %"Pd"\n",
+ bit_offset);
+ }
if (byte_offset >= data_size_in_bytes_) {
uint8_t* old_data = data_;
intptr_t old_size = data_size_in_bytes_;
@@ -72,7 +78,9 @@
bool BitmapBuilder::GetBit(intptr_t bit_offset) const {
- ASSERT(InRange(bit_offset));
+ if (!InRange(bit_offset)) {
+ return false;
+ }
intptr_t byte_offset = bit_offset >> kBitsPerByteLog2;
ASSERT(byte_offset < data_size_in_bytes_);
intptr_t bit_remainder = bit_offset & (kBitsPerByte - 1);
@@ -83,7 +91,9 @@
void BitmapBuilder::SetBit(intptr_t bit_offset, bool value) {
- ASSERT(InRange(bit_offset));
+ if (!InRange(bit_offset)) {
+ return;
srdjan 2013/06/05 15:57:21 FATAL instead of return
siva 2013/06/05 16:22:09 Done.
+ }
int byte_offset = bit_offset >> kBitsPerByteLog2;
ASSERT(byte_offset < data_size_in_bytes_);
int bit_remainder = bit_offset & (kBitsPerByte - 1);
« 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