Sfoglia il codice sorgente

make string friendly

ithewei 1 anno fa
parent
commit
e8eea95d69
1 ha cambiato i file con 4 aggiunte e 0 eliminazioni
  1. 4 0
      event/nio.c

+ 4 - 0
event/nio.c

@@ -328,6 +328,10 @@ read:
     if (nread == 0) {
         goto disconnect;
     }
+    if (nread < len) {
+        // NOTE: make string friendly
+        ((char*)buf)[nread] = '\0';
+    }
     io->readbuf.tail += nread;
     __read_cb(io, buf, nread);
     if (nread == len && !io->closed) {