parse_xml.cpp: Deserilization does not touch lastError()
The global mLastError fields for each converters can
potentially cause a segfault when a program with multiple
threads tries to deserialize a bad file at the same time.
- deserialization APIs that touches the mLastError field are
marked as non-const APIs
- const variants are provided (error is provided as an output
parameter)
- Functionalities are equivalent (tests ensure this).
Test: libvintf_test
Test: vintf_object_test
Fixes: 71874788
Change-Id: I416de909b32809a4ac377d9da998c48d7d409457
diff --git a/check_vintf.cpp b/check_vintf.cpp
index 67ecd4e..f64f81d 100644
--- a/check_vintf.cpp
+++ b/check_vintf.cpp
@@ -33,8 +33,8 @@
return nullptr;
}
auto ret = std::make_unique<T>();
- if (!converter(ret.get(), xml)) {
- std::cerr << "Error: Cannot parse '" << path << "': " << converter.lastError() << std::endl;
+ if (!converter(ret.get(), xml, &error)) {
+ std::cerr << "Error: Cannot parse '" << path << "': " << error << std::endl;
return nullptr;
}
return ret;