Fix static analyzer warnings.
Fix the following warning:
frameworks/native/libs/binder/Value.cpp:187:11: warning: Use of memory
after it is freed [clang-analyzer-cplusplus.NewDelete]
Bug: b/27101951
Test:Warnings are gone.
Change-Id: Iebd91d87dd740a39c690c25d690960f7e43d6dbe
diff --git a/libs/binder/Value.cpp b/libs/binder/Value.cpp
index fd1dfd5..85cd739 100644
--- a/libs/binder/Value.cpp
+++ b/libs/binder/Value.cpp
@@ -182,10 +182,12 @@
Value& Value::operator=(const Value& rhs)
{
- delete mContent;
- mContent = rhs.mContent
- ? rhs.mContent->clone()
- : NULL;
+ if (this != &rhs) {
+ delete mContent;
+ mContent = rhs.mContent
+ ? rhs.mContent->clone()
+ : NULL;
+ }
return *this;
}