bb#11165 - added size check to prevent invalid reads