The copy used a std::copy mechanism on optionData, which
resulted in the temporary being deleted before the function
returned. This creates a variable to hold the temporary so that
the string won't be deleted before use.
Change-Id: I5da2601b730e27d42e244b52ba6cdd69a0e28fb4
Signed-off-by: Erich Keane <erich.keane@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1622
Reviewed-by: Mandeep Shetty <mandeep.shetty@intel.com>
Reviewed-by: Omkar Hegde <omkar.m.hegde@intel.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
static_cast<uint16_t>(it->getOptionID());
response.sendVendorSpecificHeaderOptions[i].optionLength =
(it->getOptionData()).length() + 1;
- std::copy(it->getOptionData().begin(),
- it->getOptionData().end(),
+ std::string optionData = it->getOptionData();
+ std::copy(optionData.begin(),
+ optionData.end(),
response.sendVendorSpecificHeaderOptions[i].optionData);
response.sendVendorSpecificHeaderOptions[i].optionData[it->getOptionData().length()]
= '\0';