Skip to content

Commit

Permalink
Make sure to check return from fflush()
Browse files Browse the repository at this point in the history
  • Loading branch information
Gavin Howard committed Oct 10, 2018
1 parent 2ce361e commit 8c62e60
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/program.c
Original file line number Diff line number Diff line change
Expand Up @@ -1953,7 +1953,7 @@ BcStatus bc_program_printInst(BcProgram *p, char *code, size_t *bgn) {
if (inst == BC_INST_CALL) s = bc_program_printIndex(code, bgn);
}

if (!s && fflush(stdout) < 0) s = BC_STATUS_IO_ERR;
if (!s && fflush(stdout) == EOF) s = BC_STATUS_IO_ERR;

return s;
}
Expand Down
2 changes: 1 addition & 1 deletion src/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ BcStatus bc_vm_process(BcVm *vm, const char *text) {

if (BC_PARSE_CAN_EXEC(&vm->prs)) {
s = bc_program_exec(&vm->prog);
if (bcg.tty) fflush(stdout);
if (!s && bcg.tty && fflush(stdout) == EOF) s = BC_STATUS_IO_ERR;
if (s && s != BC_STATUS_QUIT)
s = bc_vm_error(bc_program_reset(&vm->prog, s), vm->prs.l.f, 0);
}
Expand Down

0 comments on commit 8c62e60

Please sign in to comment.