From fbac608cfefba27892d27ababe277b89998a8809 Mon Sep 17 00:00:00 2001 From: Manoj Gupta Date: Tue, 22 Aug 2017 15:26:11 -0700 Subject: 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 --- libs/binder/Value.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'libs') 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; } -- cgit v1.2.3-59-g8ed1b