diff options
author | Gavin D. Howard <gavin@gavinhoward.com> | 2023-02-25 23:02:25 -0700 |
---|---|---|
committer | Gavin D. Howard <gavin@gavinhoward.com> | 2023-02-25 23:02:25 -0700 |
commit | 2555a5e66dc3e8040ee3949f314dbaf52ca58695 (patch) | |
tree | 11fbd8827622a823c88ee895da3ef5b74e4bc3c0 | |
parent | 313738df7f6d65875dd91ef63565227d0f782472 (diff) | |
download | bc-2555a5e66dc3e8040ee3949f314dbaf52ca58695.tar.gz |
Fix a bug with read()
This bug was that the read buffer was not emptied between read() calls.
This one will require a new release.
Signed-off-by: Gavin D. Howard <gavin@gavinhoward.com>
-rw-r--r-- | src/program.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/program.c b/src/program.c index b6fac12c..243f827f 100644 --- a/src/program.c +++ b/src/program.c @@ -757,9 +757,16 @@ bc_program_read(BcProgram* p) // struct. bc_vec_init(&vm->read_buf, sizeof(char), BC_DTOR_NONE); } - // This needs to be updated because the parser could have been used - // somewhere else - else bc_parse_updateFunc(&vm->read_prs, BC_PROG_READ); + else + { + // This needs to be updated because the parser could have been used + // somewhere else. + bc_parse_updateFunc(&vm->read_prs, BC_PROG_READ); + + // The read buffer also needs to be emptied or else it will still + // contain previous read expressions. + bc_vec_empty(&vm->read_buf); + } BC_SETJMP_LOCKED(vm, exec_err); |