Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Improvement: Detect self reference on 'Insert...'

Aperta
#915 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

Hi there,

today I managed to produce a stupid error by copy&pasting.

Here is the minimal code snipplet:

// <foo>
auto *pElement = xmlDoc.NewElement("foo");
pElement->InsertEndChild( pElement );
/\
|__ this should have been some other parent element

The problems with the construct is that it compiles and appears to run fine until the xmlDoc is destroyed.
Then some assertions in the clean up code are triggered. Now I could see that there was a problem, but it took me some hours to
understand (and finally see) what the problem was.

I suggest to add an assertion that the pointer handed to 'InsertChildElement()' is != this
What do you think?

Best regards,
Sven

Lingua principale
C++
Stelle
5.8k
Fork
2k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di leethomason/tinyxml2

Tutte le issue di leethomason/tinyxml2

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.