rdb: fix invalid memory access

If we're actually reallocating the segement, the return value might be
different from the old segment. Don't dereference the old segment before
freeing it

Change-Id: Idee2df3fc3f609fda10bfc655e5126853b57a88f
Reviewed-on: http://review.couchbase.org/41841
Tested-by: Mark Nunberg <mnunberg@haskalah.org>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>