Check array bounds for replica index

Change-Id: I6fb59bbd9cc22e03e0632774c94f47ea5bd586cc
Reviewed-on: http://review.couchbase.org/30832
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>