From ea8109bce04434011e67eeb3abe2c71a4fa44f8b Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Tue, 5 Mar 2024 18:31:09 +0900 Subject: [PATCH] Use xmlFreeNsList to deallocate xmlNsPtr Previously xmlFree only freed the top-level allocation and not the entire linked list. Multiple namespaces should be rare but perhaps some S3 implementations have both a global and local namespace. The xmlFree(void*) prototype hid the type mismatch. --- src/s3fs.h | 5 ----- src/s3fs_xml.cpp | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/s3fs.h b/src/s3fs.h index 29c84f4..954559b 100644 --- a/src/s3fs.h +++ b/src/s3fs.h @@ -64,11 +64,6 @@ xmlFreeDoc(doc); \ S3FS_MALLOCTRIM(0); \ }while(0) -#define S3FS_XMLFREE(ptr) \ - do{ \ - xmlFree(ptr); \ - S3FS_MALLOCTRIM(0); \ - }while(0) #define S3FS_XMLXPATHFREECONTEXT(ctx) \ do{ \ xmlXPathFreeContext(ctx); \ diff --git a/src/s3fs_xml.cpp b/src/s3fs_xml.cpp index 1b9507a..5c8aabe 100644 --- a/src/s3fs_xml.cpp +++ b/src/s3fs_xml.cpp @@ -73,7 +73,7 @@ static bool GetXmlNsUrl(xmlDocPtr doc, std::string& nsurl) strNs = std::string(reinterpret_cast(nslist[0]->href), len); } } - S3FS_XMLFREE(nslist); + xmlFreeNsList(*nslist); } } }