This is unsafe. ErrorBuffer should be allocated by the client code and the error string copied in using strncpy or std::copy:

```C++
// using strncpy:
strncpy(result->ErrorBuffer, args.ErrorStr.c_str(), result->ErrorBufferSize);
if (result.ErrorBufferSize) {
    result->ErrorBuffer[result->ErrorBufferSize - 1] = '\0';
}

//using std::copy:
if (result.ErrorBufferSize) {
  std::copy(args.ErrorStr.first(), args.ErrorStr.first() + result->ErrorBufferSize - 1, result->ErrorBuffer);
  result->ErrorBuffer[result->ErrorBufferSize - 1] = '\0'
}
```