Fixed potential crash (fixed #658)