Fixed #5972 (FP: Buffer is accessed out of bounds)