Fix memory leak in binary search