fixed a potential segfault, bug#396