mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 13:39:02 +00:00
Fix buffer overflow accessing error source in ParseError::describe()
For some reason this error is triggered by tests after the Rust port of ast.cpp. Might want to get to the bottom of this but moving it back to match the original C++ logic fixes it.
This commit is contained in:
parent
386f952c53
commit
be89793669
1 changed files with 6 additions and 3 deletions
|
@ -392,18 +392,21 @@ impl ParseError {
|
|||
skip_caret: bool,
|
||||
) -> WString {
|
||||
let mut result = prefix.to_owned();
|
||||
let context = wstr::from_char_slice(
|
||||
&src.as_char_slice()[self.source_start..self.source_start + self.source_length],
|
||||
);
|
||||
// Some errors don't have their message passed in, so we construct them here.
|
||||
// This affects e.g. `eval "a=(foo)"`
|
||||
match self.code {
|
||||
ParseErrorCode::andor_in_pipeline => {
|
||||
let context = wstr::from_char_slice(
|
||||
&src.as_char_slice()[self.source_start..self.source_start + self.source_length],
|
||||
);
|
||||
result += wstr::from_char_slice(
|
||||
wgettext_fmt!(INVALID_PIPELINE_CMD_ERR_MSG, context).as_char_slice(),
|
||||
);
|
||||
}
|
||||
ParseErrorCode::bare_variable_assignment => {
|
||||
let context = wstr::from_char_slice(
|
||||
&src.as_char_slice()[self.source_start..self.source_start + self.source_length],
|
||||
);
|
||||
let assignment_src = context;
|
||||
#[allow(clippy::explicit_auto_deref)]
|
||||
let equals_pos = variable_assignment_equals_pos(assignment_src).unwrap();
|
||||
|
|
Loading…
Reference in a new issue