[IOT-1643] Fix illegal memory access - Don't return local string
authorGeorge Nash <george.nash@intel.com>
Thu, 1 Dec 2016 22:31:43 +0000 (14:31 -0800)
committerDan Mihai <Daniel.Mihai@microsoft.com>
Mon, 5 Dec 2016 16:52:22 +0000 (16:52 +0000)
commitc3df1520bf062f553a2c31d72c1fe29452dcb092
treed950e978deb9938662b658d3dc9a2668a7f31bb0
parent7935992dd59d95ac657c0645ab2e0f45155d03c4
[IOT-1643] Fix illegal memory access - Don't return local string

the std::string ret  is a local varaible and is destroyed when the
what() member function returns.

Put the return string into the m_whatMessage variable. Since
'what()' member function is a const function it can not modify the
member variable m_whatMessage so it is generated in the
ResourceInitException constructor.

Issue found using static analysis tool.

Change-Id: I907b984f35dee59b2f300afe6a640b15a26f020f
Signed-off-by: George Nash <george.nash@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/15035
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Larry Sachs <larry.j.sachs@intel.com>
Reviewed-by: Habib Virji <habib.virji@samsung.com>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
resource/include/ResourceInitException.h