out of bounds error fixed

Using CouchChat-IOS demo (great by the way) got a out of bounds error after pulling latest revision of sync_gateway. This fixes it.