summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Manoj Gupta <manojgupta@google.com> 2017-08-22 15:26:11 -0700
committer Manoj Gupta <manojgupta@google.com> 2017-08-22 15:26:11 -0700
commitfbac608cfefba27892d27ababe277b89998a8809 (patch)
tree452376cb17b35a12dec9ff962448dcdeee45cb3f
parent71f6de410f183d27485775172cb00f9c9f59951c (diff)
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
-rw-r--r--libs/binder/Value.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/libs/binder/Value.cpp b/libs/binder/Value.cpp
index fd1dfd5ada..85cd739411 100644
--- a/libs/binder/Value.cpp
+++ b/libs/binder/Value.cpp
@@ -182,10 +182,12 @@ Value& Value::swap(Value &rhs)
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;
}