mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-05 11:04:42 +03:00
Ticket #4401: Segmentation fault in mcviewer.
* (mcview_growbuf_read_until): the previous call to mcview_show_error()
invalidates sp by freeing view->ds_stdio_pipe. Reintroduce the check
that was removed in a68f2d1202
but take
sp's invalidity into account.
* (mc_pclose): add a NULL pointer check to play safe.
Signed-off-by: Michael Schuster <michael@schuster.ms>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
0ef7237eea
commit
a1f22e104d
@ -675,6 +675,13 @@ mc_pclose (mc_pipe_t * p, GError ** error)
|
|||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
|
if (p == NULL)
|
||||||
|
{
|
||||||
|
mc_replace_error (error, MC_PIPE_ERROR_READ, "%s",
|
||||||
|
_("Cannot close pipe descriptor (p == NULL)"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (p->out.fd >= 0)
|
if (p->out.fd >= 0)
|
||||||
res = close (p->out.fd);
|
res = close (p->out.fd);
|
||||||
if (p->err.fd >= 0)
|
if (p->err.fd >= 0)
|
||||||
|
@ -186,6 +186,16 @@ mcview_growbuf_read_until (WView * view, off_t ofs)
|
|||||||
view->pipe_first_err_msg = FALSE;
|
view->pipe_first_err_msg = FALSE;
|
||||||
|
|
||||||
mcview_show_error (view, sp->err.buf);
|
mcview_show_error (view, sp->err.buf);
|
||||||
|
|
||||||
|
/* when switch from parse to raw mode and back,
|
||||||
|
* do not close the already closed pipe (see call to mcview_growbuf_done below).
|
||||||
|
* return from here since (sp == view->ds_stdio_pipe) would now be invalid.
|
||||||
|
* NOTE: this check was removed by ticket #4103 but the above call to
|
||||||
|
* mcview_show_error triggers the stdio pipe handle to be closed:
|
||||||
|
* mcview_close_datasource -> mcview_growbuf_done
|
||||||
|
*/
|
||||||
|
if (view->ds_stdio_pipe == NULL)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sp->out.len > 0)
|
if (sp->out.len > 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user