Skip to content

Commit

Permalink
fix #1237 Calculate needed length in super constructor call
Browse files Browse the repository at this point in the history
  • Loading branch information
WeltWeitBau authored and hlg committed Oct 11, 2023
1 parent a1a7e95 commit dc74524
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions Shared/src/org/bimserver/shared/ByteBufferVirtualObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,13 @@ public class ByteBufferVirtualObject extends AbstractByteBufferVirtualObject imp
private Map<Integer, ByteBufferList> referencedBuffers;

public ByteBufferVirtualObject(QueryContext reusable, EClass eClass, int capacity) {
super(Math.max(capacity, 17)); // 17 bytes are always needed
super(Math.max(capacity, reusable.getPackageMetaData().getUnsettedLength(eClass) + 16)); // 16 bytes plus the class specific ones are always needed
this.reusable = reusable;
this.eClass = eClass;
this.oid = reusable.getDatabaseInterface().newOid(eClass);
this.uuid = reusable.getDatabaseInterface().newUuid();

int unsettedLength = reusable.getPackageMetaData().getUnsettedLength(eClass);
ensureCapacity(buffer.position(), 16 + unsettedLength);
buffer.put(new byte[unsettedLength]);
buffer.putLong(this.uuid.getMostSignificantBits());
buffer.putLong(this.uuid.getLeastSignificantBits());
Expand Down

0 comments on commit dc74524

Please sign in to comment.