fix potential crash when layouting lines