Fix possible range violation error when accessing the upgrade cache.