dawn/node: Handle printf() erroring
printf() can return -1 on error. In this situation, don't adjust msg with a negative offset. Fixes a spurious crash when emitting lots of text. Change-Id: Id1e9402bbbe3dd49cf08e660dea0cf67c5369516 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116289 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
e0254998cf
commit
e45bf9f3d6
|
@ -77,12 +77,12 @@ const char* str(WGPUErrorType ty) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// There's something broken with Node when attempting to write more than 65536 bytes to cout.
|
// There's something broken with Node when attempting to write more than 65536 bytes to cout.
|
||||||
// Split the string up into writes of 4k chunks .
|
// Split the string up into writes of 4k chunks.
|
||||||
// Likely related: https://github.com/nodejs/node/issues/12921
|
// Likely related: https://github.com/nodejs/node/issues/12921
|
||||||
void chunkedWrite(const char* msg) {
|
void chunkedWrite(const char* msg) {
|
||||||
while (true) {
|
while (true) {
|
||||||
auto n = printf("%.4096s", msg);
|
auto n = printf("%.4096s", msg);
|
||||||
if (n == 0) {
|
if (n <= 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
msg += n;
|
msg += n;
|
||||||
|
|
Loading…
Reference in New Issue