fdo#74209: Catch additional problem discovered.

Change-Id: Iee9b4ed4ef1fd40a9bb5a1867330d54fed4866fc
fdo#74209: This search algorithm had another issue. This fixes it.

When the search range was i.e. 1-3, and the match was found at 5, the old
code would return 5 when in fact it should have failed.  This change would
honor the end position and limit the search within specified search range.

Change-Id: If12a92fd3930ad128a5b0699a1addd96fb3a8eba