Validate the memory pointer

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