1
0
Bryan Drewery 16 жил өмнө
parent
commit
b515ba136a
1 өөрчлөгдсөн 14 нэмэгдсэн , 8 устгасан
  1. 14 8
      src/net.c

+ 14 - 8
src/net.c

@@ -1122,6 +1122,8 @@ int sockgets(char *s, int *len)
 	  return socklist[i].sock;
 	  return socklist[i].sock;
 	}
 	}
       } else {
       } else {
+        if (!socklist[i].inbuf)
+          socklist[i].inbuf = new bd::String();
         /* i dont think any of this is *ever* called */
         /* i dont think any of this is *ever* called */
 	/* Handling buffered binary data (must have been SOCK_BUFFER before). */
 	/* Handling buffered binary data (must have been SOCK_BUFFER before). */
 	if (socklist[i].inbuf->length() <= SGRAB) {
 	if (socklist[i].inbuf->length() <= SGRAB) {
@@ -1171,7 +1173,10 @@ int sockgets(char *s, int *len)
   if ((socklist[ret].flags & SOCK_LISTEN) || (socklist[ret].flags & SOCK_PASS))
   if ((socklist[ret].flags & SOCK_LISTEN) || (socklist[ret].flags & SOCK_PASS))
     return socklist[ret].sock;
     return socklist[ret].sock;
   if (socklist[ret].flags & SOCK_BUFFER) {
   if (socklist[ret].flags & SOCK_BUFFER) {
-    *(socklist[ret].inbuf) += bd::String(xx, *len);
+    if (!socklist[ret].inbuf)
+      socklist[ret].inbuf = new bd::String(xx, *len);
+    else
+      *(socklist[ret].inbuf) += bd::String(xx, *len);
     return -4;			/* Ignore this one. */
     return -4;			/* Ignore this one. */
   }
   }
   /* Might be necessary to prepend stored-up data! */
   /* Might be necessary to prepend stored-up data! */
@@ -1282,13 +1287,7 @@ void tputs(register int z, const char *s, size_t len)
 
 
       if (len && socklist[i].encstatus)
       if (len && socklist[i].encstatus)
         s = link_write(i, s, &len);
         s = link_write(i, s, &len);
-      
-      if (socklist[i].outbuf != NULL) {
-	/* Already queueing: just add it */
-        *(socklist[i].outbuf) += bd::String(s, len);
-	return;
-      }
-      /* Try. */
+
 #ifdef HAVE_ZLIB_H
 #ifdef HAVE_ZLIB_H
 /*
 /*
       if (socklist[i].gz) { 		
       if (socklist[i].gz) { 		
@@ -1299,6 +1298,13 @@ void tputs(register int z, const char *s, size_t len)
       } else
       } else
 */
 */
 #endif /* HAVE_ZLIB_H */
 #endif /* HAVE_ZLIB_H */
+
+      if (socklist[i].outbuf != NULL) {
+	/* Already queueing: just add it */
+        *(socklist[i].outbuf) += bd::String(s, len);
+	return;
+      }
+      /* Try. */
         x = write(z, s, len);
         x = write(z, s, len);
       if (x == -1)
       if (x == -1)
 	x = 0;
 	x = 0;