Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit c88de8c

Browse files
committed
abort() msg parameter escapes
1 parent 2428a74 commit c88de8c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/core/internal/abort.d

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,16 @@ void abort(scope string msg, scope string filename = __FILE__, size_t line = __L
2222
import core.sys.windows.winbase : GetStdHandle, STD_ERROR_HANDLE, WriteFile, INVALID_HANDLE_VALUE;
2323
auto h = (() @trusted => GetStdHandle(STD_ERROR_HANDLE))();
2424
if (h == INVALID_HANDLE_VALUE)
25+
{
2526
// attempt best we can to print the message
26-
assert(0, msg);
27+
28+
/* Note that msg is scope.
29+
* assert() calls _d_assert_msg() calls onAssertErrorMsg() calls _assertHandler() but
30+
* msg parameter isn't scope and can escape.
31+
* Give up and use our own immutable message instead.
32+
*/
33+
assert(0, "Cannot get stderr handle for message");
34+
}
2735
void writeStr(scope const(char)[][] m...) @nogc nothrow @trusted
2836
{
2937
foreach (s; m)

0 commit comments

Comments
 (0)