Skip to content

Commit 4948c61

Browse files
Fix new allocation size check against max size
1 parent 82fd3cb commit 4948c61

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

android-database-sqlcipher/src/main/cpp/CursorWindow.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ CursorWindow::CursorWindow(size_t initialSize, size_t growthPaddingSize, size_t
3131
mInitialSize = initialSize;
3232
mGrowthPaddingSize = growthPaddingSize;
3333
mMaxSize = maxSize;
34-
LOG_WINDOW("CursorWindow::CursorWindow initialSize:%d growBySize:%d maxSize:%d",
34+
LOG_TRACE("CursorWindow::CursorWindow initialSize:%d growBySize:%d maxSize:%d\n",
3535
initialSize, growthPaddingSize, maxSize);
3636
}
3737

@@ -43,7 +43,7 @@ bool CursorWindow::initBuffer(bool localOnly)
4343
mHeader = (window_header_t *) mData;
4444
mSize = mInitialSize;
4545
clear();
46-
LOG_WINDOW("Created CursorWindow with new MemoryDealer: mFreeOffset = %d, mSize = %d, mInitialSize = %d, mGrowthPaddingSize = %d, mMaxSize = %d, mData = %p",
46+
LOG_TRACE("Created CursorWindow with new MemoryDealer: mFreeOffset = %d, mSize = %d, mInitialSize = %d, mGrowthPaddingSize = %d, mMaxSize = %d, mData = %p\n",
4747
mFreeOffset, mSize, mInitialSize, mGrowthPaddingSize, mMaxSize, mData);
4848
return true;
4949
}
@@ -122,10 +122,10 @@ uint32_t CursorWindow::alloc(size_t requestedSize, bool aligned)
122122
}
123123
size = requestedSize + padding;
124124
if (size > freeSpace()) {
125-
LOGE("need to grow: mSize = %d, size = %d, freeSpace() = %d, numRows = %d",
125+
LOGE("need to grow: mSize = %d, size = %d, freeSpace() = %d, numRows = %d\n",
126126
mSize, size, freeSpace(), mHeader->numRows);
127127
new_allocation_sz = mSize + size - freeSpace() + mGrowthPaddingSize;
128-
if(mMaxSize == 0 || mMaxSize < new_allocation_sz) {
128+
if(mMaxSize == 0 || new_allocation_sz < mMaxSize) {
129129
tempData = realloc((void *)mData, new_allocation_sz);
130130
if(tempData == NULL) return 0;
131131
mData = (uint8_t *)tempData;

android-database-sqlcipher/src/main/java/net/sqlcipher/CursorWindow.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ public CursorWindow(boolean localWindow) {
6969
if(allocation == null){
7070
allocation = new DefaultCursorWindowAllocation();
7171
}
72-
Log.i(getClass().getSimpleName(), String.format("Calling native_init with initialAllocationSize:%d, growthPaddingSize:%d, maxAllocationSize:%d",
73-
allocation.getInitialAllocationSize(),
74-
allocation.getGrowthPaddingSize(),
75-
allocation.getMaxAllocationSize()));
7672
native_init(localWindow,
7773
allocation.getInitialAllocationSize(),
7874
allocation.getGrowthPaddingSize(),

0 commit comments

Comments
 (0)