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:
Ben Clayton 2023-01-10 14:13:50 +00:00 committed by Dawn LUCI CQ
parent e0254998cf
commit e45bf9f3d6
1 changed files with 2 additions and 2 deletions

View File

@ -82,7 +82,7 @@ const char* str(WGPUErrorType ty) {
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;