size_t optlen, const void *optval) {
int r;
- assert_return(optval, -EINVAL);
+ assert_return(optval || optlen == 0, -EINVAL);
r = option_append_hdr(buf, buflen, code, optlen);
if (r < 0)
return r;
- memcpy(*buf, optval, optlen);
+ if (optval)
+ memcpy(*buf, optval, optlen);
*buf += optlen;
*buflen -= optlen;