mrb: fix a bug that the end of code position is invalid

The problem returns wrong result for range search without index.