From da3b5a664cbd4923e14798f311bae7943b59088d Mon Sep 17 00:00:00 2001 From: AeroStun <24841307+AeroStun@users.noreply.github.com> Date: Sun, 6 Oct 2019 20:23:25 +0200 Subject: [PATCH] Fixed null pointer ASAN error introduced in commit d41b7c23 Signed-off-by: AeroStun <24841307+AeroStun@users.noreply.github.com> --- CHANGELOG.md | 1 + include/boost/beast/zlib/detail/deflate_stream.ipp | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95a28ba0..68efca35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ Version 272: * Add BEAST_THROWS +* Add zlib tests and fixes -------------------------------------------------------------------------------- diff --git a/include/boost/beast/zlib/detail/deflate_stream.ipp b/include/boost/beast/zlib/detail/deflate_stream.ipp index 8ad68262..77b8895f 100644 --- a/include/boost/beast/zlib/detail/deflate_stream.ipp +++ b/include/boost/beast/zlib/detail/deflate_stream.ipp @@ -467,7 +467,7 @@ doWrite(z_params& zs, boost::optional flush, error_code& ec) else if(flush != Flush::block) { /* FULL_FLUSH or SYNC_FLUSH */ - tr_stored_block((char*)0, 0L, 0); + tr_stored_block(nullptr, 0L, 0); /* For a full flush, this empty block will be recognized * as a special marker by inflate_sync(). */ @@ -1298,7 +1298,8 @@ copy_block( put_short((std::uint16_t)len); put_short((std::uint16_t)~len); } - std::memcpy(&pending_buf_[pending_], buf, len); + if(buf) + std::memcpy(&pending_buf_[pending_], buf, len); pending_ += len; }