MB-11305 potential dereference of NULL pointer

As identified by clang static analyser; there is a code path where
{ptr} may be NULL - if no daemon extensions are loaded
(settings.extensions.daemon is NULL) and an attempt is made to
unregister something, then {ptr} would be dereferenced at line 8054.

Same bug is also present (and fixed) in mock_server.c

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