Bug 1640041 - Don't memcpy nothing, r=jcj
authorMartin Thomson <mt@lowentropy.net>
Fri, 22 May 2020 03:26:20 +0000
changeset 15622 8d7c96ab80a78c84214b46d4fc0b8ecfd5904cb3
parent 15621 1a634da46b875c11bf53313ce2b801896a45b265
child 15623 98390eef50a10d496d35e38ef03f2248a47abd92
push id3750
push usermthomson@mozilla.com
push dateFri, 22 May 2020 03:26:49 +0000
reviewersjcj
bugs1640041
Bug 1640041 - Don't memcpy nothing, r=jcj Depends on D76421 Differential Revision: https://phabricator.services.mozilla.com/D76422
lib/ssl/sslencode.c
--- a/lib/ssl/sslencode.c
+++ b/lib/ssl/sslencode.c
@@ -59,17 +59,20 @@ sslBuffer_Grow(sslBuffer *b, unsigned in
 
 SECStatus
 sslBuffer_Append(sslBuffer *b, const void *data, unsigned int len)
 {
     SECStatus rv = sslBuffer_Grow(b, b->len + len);
     if (rv != SECSuccess) {
         return SECFailure; /* Code already set. */
     }
-    PORT_Memcpy(SSL_BUFFER_NEXT(b), data, len);
+    if (len > 0) {
+        PORT_Assert(data);
+        PORT_Memcpy(SSL_BUFFER_NEXT(b), data, len);
+    }
     b->len += len;
     return SECSuccess;
 }
 
 SECStatus
 sslBuffer_AppendNumber(sslBuffer *b, PRUint64 v, unsigned int size)
 {
     SECStatus rv = sslBuffer_Grow(b, b->len + size);