Fix off-by-1 bug in expandable bit vectors.
Bug: 3224068
Change-Id: I6e5e956da380262e65cb1da9bcc51ba31f5b0d14
diff --git a/vm/compiler/Utility.c b/vm/compiler/Utility.c
index 711d4cf..daeb893 100644
--- a/vm/compiler/Utility.c
+++ b/vm/compiler/Utility.c
@@ -277,7 +277,8 @@
if (!pBits->expandable)
return false;
- int newSize = (num + 31) >> 5;
+ /* Round up to word boundaries for "num+1" bits */
+ int newSize = (num + 1 + 31) >> 5;
assert(newSize > pBits->storageSize);
u4 *newStorage = dvmCompilerNew(newSize * sizeof(u4), false);
memcpy(newStorage, pBits->storage, pBits->storageSize * sizeof(u4));