Fixed #5158 (segmentation fault (valid code))