From 8d758a1ba07e739970d4badf6e7105ba6068bf64 Mon Sep 17 00:00:00 2001 From: joe-redpanda Date: Wed, 19 Nov 2025 10:33:39 -0800 Subject: [PATCH] packet.hh: add assert on len() An assert which checks the validity of _impl before calling into it. This assert is meant to rotate previously seen undefined behavior into a node crash. --- include/seastar/net/packet.hh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/seastar/net/packet.hh b/include/seastar/net/packet.hh index 1fefada7b8d..dda38f5c48e 100644 --- a/include/seastar/net/packet.hh +++ b/include/seastar/net/packet.hh @@ -237,7 +237,10 @@ public: return *this; } - unsigned len() const noexcept { return _impl->_len; } + unsigned len() const noexcept { + SEASTAR_ASSERT(_impl); + return _impl->_len; + } unsigned memory() const noexcept { return len() + sizeof(packet::impl); } fragment frag(unsigned idx) const noexcept { return _impl->_frags[idx]; }