diff buffer.c @ 1049:01eea88963f3 fastopen

merge from default
author Matt Johnston <matt@ucc.asn.au>
date Sat, 28 Feb 2015 09:06:40 +0800
parents a5b785c12340
children 16584026a1f0
line wrap: on
line diff
--- a/buffer.c	Fri Feb 27 00:02:48 2015 +0800
+++ b/buffer.c	Sat Feb 28 09:06:40 2015 +0800
@@ -99,7 +99,9 @@
 
 	ret = buf_new(buf->len);
 	ret->len = buf->len;
-	memcpy(ret->data, buf->data, buf->len);
+	if (buf->len > 0) {
+	    memcpy(ret->data, buf->data, buf->len);
+	}
 	return ret;
 }
 
@@ -127,7 +129,7 @@
 	buf->pos = pos;
 }
 
-/* increment the postion by incr, increasing the buffer length if required */
+/* increment the position by incr, increasing the buffer length if required */
 void buf_incrwritepos(buffer* buf, unsigned int incr) {
 	if (incr > BUF_MAX_INCR || buf->pos + incr > buf->size) {
 		dropbear_exit("Bad buf_incrwritepos");