Exit when QemuPipe is corrupted by GL

Previously when QemuPipe is corrupted, it prints an error message, and
the application will continue to use it, which leads to random behaviour
in GL on the host.

This patch crashes the APP and pops up the crash dialog when the pipe is
(going to be) corrupted. It would happen if the user asks GL to write /
read a NULL pointer (i.e. passing NULL to glGenBuffers). It might also
happen for other unknown reasons.

Change-Id: I303772029bb72a845fa0d4c79b0d38dba1fca2c7
(cherry picked from commit 5bc2615d233a2a5de39f1033be4f063d0ae8f5e4)
diff --git a/opengl/system/OpenglSystemCommon/QemuPipeStream.cpp b/opengl/system/OpenglSystemCommon/QemuPipeStream.cpp
index 3a53161..581aec3 100644
--- a/opengl/system/OpenglSystemCommon/QemuPipeStream.cpp
+++ b/opengl/system/OpenglSystemCommon/QemuPipeStream.cpp
@@ -88,8 +88,14 @@
     //DBG(">> QemuPipeStream::writeFully %d\n", len);
     if (!valid()) return -1;
     if (!buf) {
-        if (len>0) ERR("QemuPipeStream::writeFully failed, buf=NULL, len %d", len);
-        return 0;
+       if (len>0) {
+            // If len is non-zero, buf must not be NULL. Otherwise the pipe would be
+            // in a corrupted state, which is lethal for the emulator.
+           ERR("QemuPipeStream::writeFully failed, buf=NULL, len %d,"
+                   " lethal error, exiting", len);
+           abort();
+       }
+       return 0;
     }
 
     size_t res = len;
@@ -110,8 +116,9 @@
             continue;
         }
         retval =  stat;
-        ERR("QemuPipeStream::writeFully failed: %s\n", strerror(errno));
-        break;
+        ERR("QemuPipeStream::writeFully failed: %s, lethal error, exiting.\n",
+                strerror(errno));
+        abort();
     }
     //DBG("<< QemuPipeStream::writeFully %d\n", len );
     return retval;
@@ -123,7 +130,11 @@
     if (!valid()) return NULL;
     if (!buf) {
         if (len > 0) {
-            ERR("QemuPipeStream::readFully failed, buf=NULL, len %zu", len);
+            // If len is non-zero, buf must not be NULL. Otherwise the pipe would be
+            // in a corrupted state, which is lethal for the emulator.
+            ERR("QemuPipeStream::readFully failed, buf=NULL, len %zu, lethal"
+                    " error, exiting.", len);
+            abort();
         }
         return NULL;  // do not allow NULL buf in that implementation
     }
@@ -138,8 +149,9 @@
                 continue;
             } else {
                 ERR("QemuPipeStream::readFully failed (buf %p, len %zu"
-                    ", res %zu): %s\n", buf, len, res, strerror(errno));
-                return NULL;
+                    ", res %zu): %s, lethal error, exiting.", buf, len, res,
+                    strerror(errno));
+                abort();
             }
         } else {
             res -= stat;