Allegedly the behavior of memcpy() is undefined if the source
pointer is NULL, even if the number of bytes to copy is zero.
bi_windup(s); /* align on byte boundary */
put_short(s, (uint16_t)stored_len);
put_short(s, (uint16_t)~stored_len);
- memcpy(s->pending_buf + s->pending, (unsigned char *)buf, stored_len);
+ if (stored_len)
+ memcpy(s->pending_buf + s->pending, (unsigned char *)buf, stored_len);
s->pending += stored_len;
#ifdef ZLIB_DEBUG
s->compressed_len = (s->compressed_len + 3 + 7) & (unsigned long)~7L;