diff options
| author | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-10-19 22:00:50 +0200 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-10-19 22:00:50 +0200 |
| commit | 82f783595f654b62ce57a7cfb537d23efce7affc (patch) | |
| tree | 32806d5e2a54c7c47459124c1df15b7e47c8d71b /libs/xml.c | |
| parent | 3e85a8e6db1a9c9a7fcf7974a1a0307b2cb145bd (diff) | |
fix r/w mem leaks
Diffstat (limited to 'libs/xml.c')
| -rw-r--r-- | libs/xml.c/src/xml.c | 10 | ||||
| -rw-r--r-- | libs/xml.c/src/xml.h | 2 |
2 files changed, 10 insertions, 2 deletions
diff --git a/libs/xml.c/src/xml.c b/libs/xml.c/src/xml.c index 0a93e57..6d14213 100644 --- a/libs/xml.c/src/xml.c +++ b/libs/xml.c/src/xml.c @@ -820,7 +820,15 @@ exit_failure: } - +bool xml_string_is_valid(uint8_t* buffer, size_t length) +{ + struct xml_document* doc = xml_parse_document(buffer, length); + if (!doc) { + return 0; + } + xml_document_free(doc, false); + return 1; +} /** diff --git a/libs/xml.c/src/xml.h b/libs/xml.c/src/xml.h index 65a7b9f..ef8d55c 100644 --- a/libs/xml.c/src/xml.h +++ b/libs/xml.c/src/xml.h @@ -64,7 +64,7 @@ struct xml_string; * @return The parsed xml fragment iff parsing was successful, 0 otherwise */ struct xml_document* xml_parse_document(uint8_t* buffer, size_t length); - +bool xml_string_is_valid(uint8_t* buffer, size_t length); /** |
