Itseez/opencv — pull request #3058 by PhilLab (2014-08-07 17:11:40+00:00)
Title: Fixed self-assignment in cv::Ptr::operator =

A self-assignment leads to a call of release() with refcount being 2. In the release() method, refcount is decremented and then successfully checked for being 1. As a consequence, the underlying data is released. To prevent this, we test for a self-assignment.

The current error can be reproduced by executing the following statements:
```cpp
cv::Ptr a(new cv::Mat(5,5, CV_8UC3));
a->setTo(100);
a = a;
cv::imshow("test", *a);
```