diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2016-03-13 20:21:00 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2016-04-04 06:35:54 +0300 |
commit | 124c3594cb65748ce858dcc55eadd7c831cee041 (patch) | |
tree | e31cf88a4231a756e63dd9350ff54d326e7ae331 /builtin.c | |
parent | 7a1dafd29d4ec5d8868f5ea376a99422a9282cdb (diff) | |
download | egawk-124c3594cb65748ce858dcc55eadd7c831cee041.tar.gz egawk-124c3594cb65748ce858dcc55eadd7c831cee041.tar.bz2 egawk-124c3594cb65748ce858dcc55eadd7c831cee041.zip |
Initial fix for use of closed end of two-way connection.
Diffstat (limited to 'builtin.c')
-rw-r--r-- | builtin.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -1664,8 +1664,12 @@ do_printf(int nargs, int redirtype) if (redir_exp->type != Node_val) fatal(_("attempt to use array `%s' in a scalar context"), array_vname(redir_exp)); rp = redirect(redir_exp, redirtype, & errflg); - if (rp != NULL) + if (rp != NULL) { + if ((rp->flag & RED_TWOWAY) != 0 && rp->output.fp == NULL) { + fatal(_("printf: attempt to write to closed write end of two-way pipe")); + } fp = rp->output.fp; + } } else if (do_debug) /* only the debugger can change the default output */ fp = output_fp; else @@ -2136,8 +2140,12 @@ do_print(int nargs, int redirtype) if (redir_exp->type != Node_val) fatal(_("attempt to use array `%s' in a scalar context"), array_vname(redir_exp)); rp = redirect(redir_exp, redirtype, & errflg); - if (rp != NULL) + if (rp != NULL) { + if ((rp->flag & RED_TWOWAY) != 0 && rp->output.fp == NULL) { + fatal(_("print: attempt to write to closed write end of two-way pipe")); + } fp = rp->output.fp; + } } else if (do_debug) /* only the debugger can change the default output */ fp = output_fp; else |