boostorg / boostorg/python

boost::python handle& operator=() is not implemented correctly

Offen
#190 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
C++
Sterne
537
Forks
223
Ø Merge
11 Std. 22 Min.
Gemergte PRs (30 T.)
2

Beschreibung

The assignment operator for a handle is implemented by first decreasing the reference count of the contained object and then incrementing the one of the right hand side.

```python
python::xdecref(m_p);
m_p = python::xincref(r.m_p);
```

This is not the correct order but should be the other way round, i.e. first incrementing than decrementing. This is also the effect described in the documentation.

```python
python::xincref(r.m_p)
python::xdecref(m_p);
m_p = r.m_p
```

By doing it the current way, self assignment increases the reference count of a potentially already freed object.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.