From 28c8105687c9b883c2eee8b3357af322fe52ff4e Mon Sep 17 00:00:00 2001 From: Masaori Koshiba Date: Fri, 17 Jan 2025 08:26:10 +0900 Subject: [PATCH] Add nullptr check in PluginVC read and write (#11961) --- src/proxy/PluginVC.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/proxy/PluginVC.cc b/src/proxy/PluginVC.cc index b9ca711a4e7..427b271eba2 100644 --- a/src/proxy/PluginVC.cc +++ b/src/proxy/PluginVC.cc @@ -483,7 +483,7 @@ PluginVC::process_write_side() need_write_process = false; // Check write_state - if (write_state.vio.op != VIO::WRITE || closed || write_state.shutdown) { + if (write_state.vio.cont == nullptr || write_state.vio.op != VIO::WRITE || closed || write_state.shutdown) { return; } @@ -493,9 +493,13 @@ PluginVC::process_write_side() return; } - IOBufferReader *reader = write_state.vio.get_reader(); - int64_t bytes_avail = reader->read_avail(); - int64_t act_on = std::min(bytes_avail, ntodo); + IOBufferReader *reader = write_state.vio.get_reader(); + if (reader == nullptr) { + return; + } + + int64_t bytes_avail = reader->read_avail(); + int64_t act_on = std::min(bytes_avail, ntodo); Dbg(dbg_ctl_pvc, "[%u] %s: process_write_side; act_on %" PRId64 "", core_obj->id, PVC_TYPE, act_on); @@ -601,7 +605,8 @@ PluginVC::process_read_side() need_read_process = false; // Check read_state - if (read_state.vio.op != VIO::READ || closed || read_state.shutdown || !read_state.vio.ntodo()) { + if (read_state.vio.cont == nullptr || read_state.vio.op != VIO::READ || closed || read_state.shutdown || + !read_state.vio.ntodo()) { return; }