Fix ticket #4922 (segmentation fault upon invalid code).