Skip to content

Commit

Permalink
Fix buffer capacity race condition in spatial (apache#16931)
Browse files Browse the repository at this point in the history
  • Loading branch information
pranavbhole authored Aug 27, 2024
1 parent f8301a3 commit 0caf383
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ public ImmutableBitmap getImmutableBitmap()
{
final int sizePosition = initialOffset + offsetFromInitial + HEADER_NUM_BYTES + 2 * numDims * Float.BYTES;
int numBytes = data.getInt(sizePosition);
data.position(sizePosition + Integer.BYTES);
ByteBuffer tmpBuffer = data.slice();
tmpBuffer.limit(numBytes);
return bitmapFactory.mapImmutableBitmap(tmpBuffer.asReadOnlyBuffer());
final ByteBuffer readOnlyBuffer = data.asReadOnlyBuffer();
readOnlyBuffer.position(sizePosition + Integer.BYTES);
readOnlyBuffer.limit(readOnlyBuffer.position() + numBytes);
return bitmapFactory.mapImmutableBitmap(readOnlyBuffer);
}

@Override
Expand Down

0 comments on commit 0caf383

Please sign in to comment.