Fix the unbounded check for merge
Merge pull request #1530 from zsxwing/issue-merge

Fix the unbounded check for merge