mirror of
https://github.com/Hopiu/micro.git
synced 2026-03-17 06:20:28 +00:00
save: Restore the screen if failed to start sudo (#2971)
Similarly to the crash fixed by #2967, which happens if sudo failed, a crash also happens when sudo even fails to start. The reason for the crash is also similar: nil dereference of screen.Screen caused by the fact that we do not restore temporarily disabled screen. To reproduce this crash, set the `sucmd` option to some non-existing command, e.g. `aaa`, and try to save a file with root privileges.
This commit is contained in:
parent
1231d24279
commit
db6d4f5461
1 changed files with 1 additions and 0 deletions
|
|
@ -51,6 +51,7 @@ func overwriteFile(name string, enc encoding.Encoding, fn func(io.Writer) error,
|
|||
// contents to its stdin it might hang because the kernel's pipe size
|
||||
// is too small to handle the full file contents all at once
|
||||
if e := cmd.Start(); e != nil && err == nil {
|
||||
screen.TempStart(screenb)
|
||||
return err
|
||||
}
|
||||
} else if writeCloser, err = os.OpenFile(name, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644); err != nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue