fix a segfault problem in swift
Merge pull request #803 from LipuFei/fix_swift

fix a segfault problem in swift