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>
diff --git a/src/dawn/node/binding/GPUDevice.cpp b/src/dawn/node/binding/GPUDevice.cpp
index 3623621..9e0baa7 100644
--- a/src/dawn/node/binding/GPUDevice.cpp
+++ b/src/dawn/node/binding/GPUDevice.cpp
@@ -77,12 +77,12 @@
 }
 
 // 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
 void chunkedWrite(const char* msg) {
     while (true) {
         auto n = printf("%.4096s", msg);
-        if (n == 0) {
+        if (n <= 0) {
             break;
         }
         msg += n;