script: avoid trying fclose(NULL)

Here is a one-liner to reproduce the issue.

$ mkdir example && cd example && chmod 0500 . && script
Script started, file is typescript
script: cannot open typescript: Permission denied
                                                 Script done, file is typescript
Segmentation fault (core dumped)

Addresses: https://bugs.launchpad.net/bugs/1537518
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2016-04-16 17:43:01 +01:00
parent 400423824a
commit 4b0b416acb
No known key found for this signature in database
GPG Key ID: A9553245FDE9B739
1 changed files with 2 additions and 1 deletions

View File

@ -205,7 +205,8 @@ static void __attribute__((__noreturn__)) done(struct script_control *ctl)
if (ctl->timingfp)
fclose(ctl->timingfp);
fclose(ctl->typescriptfp);
if (ctl->typescriptfp)
fclose(ctl->typescriptfp);
if (ctl->rc_wanted) {
if (WIFSIGNALED(ctl->childstatus))