Patches: do not look beyond upper limit for search pattern