From 204e17171b4bbaf171e7565d59143f3cee0a70b9 Mon Sep 17 00:00:00 2001 From: Gabriel Biren Date: Thu, 16 Feb 2023 18:10:17 +0000 Subject: [PATCH] Free version buffer in the Vendor HAL's XML parsing logic. Fixes a minor memory leak that results from not freeing that buffer. Bug: 269520490 Test: Manual test 1. Create several XML files under /vendor/etc/wifi/vendor_hals 2. Modify the codepath to run the initVendorHalsDescriptorList method (does not run by default on Pixel). 3. Check that the XML parsing logic is working as intended. Change-Id: I42944169b70c759998d94e8523d2aa55d0366ffd --- wifi/aidl/default/wifi_legacy_hal_factory.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wifi/aidl/default/wifi_legacy_hal_factory.cpp b/wifi/aidl/default/wifi_legacy_hal_factory.cpp index 60f81ed764..0359d6f13f 100644 --- a/wifi/aidl/default/wifi_legacy_hal_factory.cpp +++ b/wifi/aidl/default/wifi_legacy_hal_factory.cpp @@ -128,7 +128,7 @@ bool WifiLegacyHalFactory::initLinkedHalFunctionTable(wifi_hal_fn* hal_fn) { void WifiLegacyHalFactory::initVendorHalsDescriptorList() { xmlDocPtr xml; xmlNodePtr node, cnode; - char* version; + char* version = NULL; std::string path; xmlChar* value; wifi_hal_lib_desc desc; @@ -200,6 +200,10 @@ void WifiLegacyHalFactory::initVendorHalsDescriptorList() { } skip: xmlFreeDoc(xml); + if (version) { + xmlFree(version); + version = NULL; + } } ::closedir(dirPtr); }