diff options
author | Nicolas Williams <nico@cryptonector.com> | 2014-08-30 00:27:26 -0500 |
---|---|---|
committer | Nicolas Williams <nico@cryptonector.com> | 2014-08-30 00:40:03 -0500 |
commit | b70bea8d34b2e62444ca1dffe5ce320a0772a834 (patch) | |
tree | 08324435f3edf3b8da29b616cf0853f980a5be2e /main.c | |
parent | d177944b75fc7fd116c09d90d71e6fcbd1c2ed52 (diff) |
Handle invalid inputs in argument files (fix #562)
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -155,8 +155,10 @@ static int read_more(char* buf, size_t size, int* islast) { current_input = 0; } if (next_input_idx == ninput_files) { + assert(*islast == 1); return 0; } + *islast = 0; if (!strcmp(input_filenames[next_input_idx], "-")) { current_input = stdin; } else { @@ -168,8 +170,8 @@ static int read_more(char* buf, size_t size, int* islast) { next_input_idx++; } - if (next_input_idx == ninput_files) *islast = 1; if (!fgets(buf, size, current_input)) buf[0] = 0; + if (!current_input || feof(current_input)) *islast = 1; return 1; } @@ -453,7 +455,7 @@ int main(int argc, char* argv[]) { } } } else { - jv_parser_set_buf(parser, buf, strlen(buf), !(is_last || feof(stdin))); + jv_parser_set_buf(parser, buf, strlen(buf), !is_last); jv value; while (jv_is_valid((value = jv_parser_next(parser)))) { if (options & SLURP) { |