Fixed segfault when queue_length=0