Fix null c_str converted to std::string causes SIGSEGV
Test: libvintf_test
Test: adb shell /system/bin/vintf
Change-Id: I01063d8275b03411acb8a35aaf4518dc923d6d7d
diff --git a/parse_xml.cpp b/parse_xml.cpp
index a8be3bb..3070771 100644
--- a/parse_xml.cpp
+++ b/parse_xml.cpp
@@ -84,11 +84,11 @@
}
inline std::string nameOf(NodeType *root) {
- return root->Name();
+ return root->Name() == NULL ? "" : root->Name();
}
inline std::string getText(NodeType *root) {
- return root->GetText();
+ return root->GetText() == NULL ? "" : root->GetText();
}
inline NodeType *getChild(NodeType *parent, const std::string &name) {