CCBC-268 Check bounds when calculating replica node index

Change-Id: Ied314cb9d467778e1a23aea402511901cdbe14d6
Reviewed-on: http://review.couchbase.org/28895
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Do not continue execution after memory error

Change-Id: I546ac12417d3359ed71b53870698a8a9a1013c77
Reviewed-on: http://review.couchbase.org/28926
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Mark Nunberg <mnunberg@haskalah.org>
lcb_gai2sock_v1() might return NULL, check for it before using

Change-Id: Ib17c8c9a544f1d506f5bf3e45fc743b7553acc97
Reviewed-on: http://review.couchbase.org/28934
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>