fixed possible memory leaks in the constructor and assignment operator of SharedPtr reported by issue #287