diff --git a/src/server/worker_task.rs b/src/server/worker_task.rs index 0f7e291a..771e8447 100644 --- a/src/server/worker_task.rs +++ b/src/server/worker_task.rs @@ -210,7 +210,7 @@ pub fn upid_read_status(upid: &UPID) -> Result { file.read_to_end(&mut data)?; // task logs should end with newline, we do not want it here - if data[data.len()-1] == b'\n' { + if data.len() > 0 && data[data.len()-1] == b'\n' { data.pop(); } @@ -218,7 +218,7 @@ pub fn upid_read_status(upid: &UPID) -> Result { let mut start = 0; for pos in (0..data.len()).rev() { if data[pos] == b'\n' { - start = pos + 1; + start = data.len().min(pos + 1); break; } }