MB-8149 Possibly dangling pointer

Change-Id: Ibb1e4c14598d587aa2bab8dff1c113c3391573db
Reviewed-on: http://review.couchbase.org/28674
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>