Fix bounds check on library search pattern