Skip to content

Commit

Permalink
Check error buffer has sufficient capacity before access.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjpt777 committed Apr 11, 2022
1 parent 32db1fb commit efa1bff
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import org.agrona.concurrent.AtomicBuffer;

import static org.agrona.BitUtil.SIZE_OF_INT;
import static org.agrona.BitUtil.align;
import static org.agrona.concurrent.errors.DistinctErrorLog.*;

Expand All @@ -35,7 +36,7 @@ public class ErrorLogReader
*/
public static boolean hasErrors(final AtomicBuffer buffer)
{
return buffer.capacity() > 0 && 0 != buffer.getIntVolatile(LENGTH_OFFSET);
return buffer.capacity() >= SIZE_OF_INT && 0 != buffer.getIntVolatile(LENGTH_OFFSET);
}

/**
Expand Down

0 comments on commit efa1bff

Please sign in to comment.