Make operator= and constructor behavior consistent.
hidl_string(nullptr) == "". Now so does operator=(nullptr).
Bug: 35421240
Test: libhidl_test
Change-Id: Ib62fa71ab47a407b7017c809783dd5f421b98e39
diff --git a/base/HidlSupport.cpp b/base/HidlSupport.cpp
index ec5b18f..6f04838 100644
--- a/base/HidlSupport.cpp
+++ b/base/HidlSupport.cpp
@@ -239,6 +239,11 @@
hidl_string &hidl_string::operator=(const char *s) {
clear();
+
+ if (s == nullptr) {
+ return *this;
+ }
+
copyFrom(s, strlen(s));
return *this;
}