diff options
author | Marek Chalupa <chalupa@fi.muni.cz> | 2020-01-27 15:33:50 +0100 |
---|---|---|
committer | Cristian Cadar <c.cadar@imperial.ac.uk> | 2020-04-08 13:23:45 +0100 |
commit | d4f759bcb0280cf36b14d1be4fa4c3e109958ae0 (patch) | |
tree | 65a1e34a41f62bb57721c06d1b0849bc53cf82a2 /lib/Core | |
parent | bb933726973a7fbdbc59953dfe7ca4cfc242e971 (diff) | |
download | klee-d4f759bcb0280cf36b14d1be4fa4c3e109958ae0.tar.gz |
readStringAtAddress: use stringstream to obtain the string
The code is simpler and more in the spirit of C++.
Diffstat (limited to 'lib/Core')
-rw-r--r-- | lib/Core/SpecialFunctionHandler.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
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<ConstantExpr>(cur) && "hit symbolic char while reading concrete string"); - buf[i] = cast<ConstantExpr>(cur)->getZExtValue(8); + buf << static_cast<char>(cast<ConstantExpr>(cur)->getZExtValue(8)); } - buf[i] = 0; - - std::string result(buf); - delete[] buf; - return result; + + return buf.str(); } /****/ |