Fixed crash due to invalid memory access.