michaelrsweet / mxml

Tiny XML library.
https://www.msweet.org/mxml
Apache License 2.0
426 stars 157 forks source link

Memory leak in mxml_load_data() error handling #278

Closed TrondKjeldas closed 2 years ago

TrondKjeldas commented 3 years ago

If the mxml_load_data() function bails out at the ‘goto error’ statement at approx line 1978 it never releases the ‘node’ pointer allocated a few lines further up.

The issue can be reproduced by feeding the mxmlLoadString() function with a 0-terminated string containing only the two characters ‘<‘ and ‘\n’.

TrondKjeldas commented 3 years ago

I have found a few more cases where there is memory leak.

I have a fix that fixes all these cases for me, and will try to submit a pull request.

michaelrsweet commented 3 years ago

@TrondKjeldas Thanks!

TrondKjeldas commented 3 years ago

This seems to work fine for me: #279