Avoid buffer overrun on mouse clicks