shared: possible use after free fix

Signed-off-by: Michael Leibowitz <michael.leibowitz@intel.com>