From d4f759bcb0280cf36b14d1be4fa4c3e109958ae0 Mon Sep 17 00:00:00 2001 From: Marek Chalupa Date: Mon, 27 Jan 2020 15:33:50 +0100 Subject: readStringAtAddress: use stringstream to obtain the string The code is simpler and more in the spirit of C++. --- lib/Core/SpecialFunctionHandler.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'lib/Core') diff --git a/lib/Core/SpecialFunctionHandler.cpp b/lib/Core/SpecialFunctionHandler.cpp index bae8085d..dbc8f190 100644 --- a/lib/Core/SpecialFunctionHandler.cpp +++ b/lib/Core/SpecialFunctionHandler.cpp @@ -259,7 +259,7 @@ SpecialFunctionHandler::readStringAtAddress(ExecutionState &state, const MemoryObject *mo = op.first; const ObjectState *os = op.second; - char *buf = new char[mo->size]; + std::ostringstream buf; unsigned i; for (i = 0; i < mo->size - 1; i++) { @@ -267,13 +267,10 @@ SpecialFunctionHandler::readStringAtAddress(ExecutionState &state, cur = executor.toUnique(state, cur); assert(isa(cur) && "hit symbolic char while reading concrete string"); - buf[i] = cast(cur)->getZExtValue(8); + buf << static_cast(cast(cur)->getZExtValue(8)); } - buf[i] = 0; - - std::string result(buf); - delete[] buf; - return result; + + return buf.str(); } /****/ -- cgit 1.4.1