fix crash in issue #231

@radumereuta please review