Make sure we own the pointer we are trying to get a size for

This chnge fixes a crash on windows operating systems.

Change-Id: Ie91679412ad74794697c54a0699db70ed86a2e8f
Reviewed-on: http://review.couchbase.org/30547
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>