在 2022/3/16 10:58, Thomas Faber 写道:
While examining the `ConvertBSTRToString()` function, I noticed some issues in it. (I am
not sure
whether this is a correct place to ask, but I decide not to cross post.)
1) According to MS docs [1], `ConvertBSTRToString()` returns a string
that the user must delete via `delete[]`, so why is the returned
buffer allocated via `::operator new()`, instead of `new char[...]`?
2) `::operator new()` throws an exception on failure and never returns
a null pointer. This makes the null check about its return value
unnecessary. Is it supposed to be `::new(::std::nothrow) char[...]`?
Or do we ignore such circumstances?
[1]
https://docs.microsoft.com/en-us/cpp/cpp/convertbstrtostring?view=msvc-170
--
Best regards,
LIU Hao