|
Boost Users : |
From: Darin Adler (darin_at_[hidden])
Date: 2001-12-14 16:41:33
On 12/14/01 1:40 PM, "Louis Lavery" <Louis_at_[hidden]> wrote:
> Yes, I see that, but I can't see what's wrong with using the
> test "if ( px != rpx )".
>
> Or, to put it another way, if px == rpx == 0 who cares whether
> pn equals rpn or not?
If both px and rpx are 0, but pn and rpn are the same, then the dispose()
will cause the single object pointed to by pn to be deleted.
Then pn will point to freed memory. And dereferencing pn will result in
undefined behavior. And destroying the shared_ptr will result in undefined
behavior because it will try to delete the same thing again.
-- Darin
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net