mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 03:54:04 +08:00
Clean up some memory allocation in builtin_commandline
This commit is contained in:
parent
d62694a9ce
commit
b3b83449cf
|
@ -480,16 +480,7 @@ static int builtin_commandline(parser_t &parser, wchar_t **argv)
|
||||||
const wchar_t *buffer = reader_get_buffer();
|
const wchar_t *buffer = reader_get_buffer();
|
||||||
if (reader_get_selection(&start, &len))
|
if (reader_get_selection(&start, &len))
|
||||||
{
|
{
|
||||||
wchar_t *selection = new wchar_t[len + 1];
|
stdout_buffer.append(buffer + start, len);
|
||||||
selection[len] = L'\0';
|
|
||||||
selection = wcsncpy(selection, buffer + start, len);
|
|
||||||
|
|
||||||
append_format(stdout_buffer, selection);
|
|
||||||
delete selection;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
append_format(stdout_buffer, L"");
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user