Fix buffer overrun

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