Skip to content

Commit a173d01

Browse files
committed
Fix potential memory leak when loading bad XML (Issue #354)
1 parent c499df4 commit a173d01

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎CHANGES.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ v4.0.5 (YYYY-MM-DD)
99
- Added support for Windows on ARM64 (Issue #352)
1010
- Fixed build issues with MingW (Issue #347)
1111
- Fixed an access issue in `mxmlIndexNew` (Issue #350)
12+
- Fixed a potential memory leak when loading bad XML (Issue #354)
1213

1314

1415
v4.0.4 (2025-01-19)

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ tree:
170170
Getting Help And Reporting Problems
171171
-----------------------------------
172172

173-
The [Mini-XML project page](https://www.msweet.org/mxml) provides access to the
173+
The [Mini-XML project page](https://www.msweet.org/mxml/) provides access to the
174174
current version of this software, documentation, and Github issue tracking page.
175175

176176

‎mxml-file.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,8 +1343,6 @@ mxml_load_data(
13431343
if ((ch = mxml_getc(options, io_cb, io_cbdata, &encoding)) != '>')
13441344
{
13451345
_mxml_error(options, "Expected > but got '%c' instead for element <%s/> on line %d.", ch, buffer, line);
1346-
mxmlDelete(node);
1347-
node = NULL;
13481346
goto error;
13491347
}
13501348

@@ -1439,6 +1437,9 @@ mxml_load_data(
14391437
// Common error return...
14401438
error:
14411439

1440+
if (node && node != first)
1441+
mxmlDelete(node);
1442+
14421443
mxmlDelete(first);
14431444

14441445
free(buffer);

0 commit comments

Comments
 (0)