mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
libsolc: truncate input C strings to trailing zero
This commit is contained in:
parent
b7d6e44af7
commit
d8d6cae525
@ -62,6 +62,14 @@ string takeOverAllocation(char const* _data)
|
||||
abort();
|
||||
}
|
||||
|
||||
/// Resizes a std::string to the proper length based on the occurrence of a zero terminator.
|
||||
void truncateCString(string& _data)
|
||||
{
|
||||
size_t pos = _data.find('\0');
|
||||
if (pos != string::npos)
|
||||
_data.resize(pos);
|
||||
}
|
||||
|
||||
ReadCallback::Callback wrapReadCallback(CStyleReadFileCallback _readCallback, void* _readContext)
|
||||
{
|
||||
ReadCallback::Callback readCallback;
|
||||
@ -89,6 +97,7 @@ ReadCallback::Callback wrapReadCallback(CStyleReadFileCallback _readCallback, vo
|
||||
result.success = false;
|
||||
result.responseOrErrorMessage = takeOverAllocation(error_c);
|
||||
}
|
||||
truncateCString(result.responseOrErrorMessage);
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user