Skip to content

Commit

Permalink
Add nullptr check in PluginVC read and write (#11961)
Browse files Browse the repository at this point in the history
  • Loading branch information
masaori335 authored Jan 16, 2025
1 parent 0c1b142 commit 28c8105
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/proxy/PluginVC.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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);

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 28c8105

Please sign in to comment.