fixed a bug which could cause server segmentation fault with a crafted query