From 22d4e6a05dba955bd74f3ae1dd52bef3876eef64 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 15 Oct 2002 00:23:54 -0500 Subject: [svn-r6000] Purpose: Bug fix (ID 765 and part of ID 841) Description: "h5dump -H" would core dump. It was because the code was not checking if there was any file argument after option parsing. It referred to an non-existing filename argument. There was also some very old but not commented code which allowed the use of back slash to escape a filename begun with '-'. The '--' option is better and more common practice. Solution: Added code to check if there is still a filename argument after parsing. (This checking probably should goto inside the option_parsing routine. Also removed that old code mentioned above. Platforms tested: eirene, arabica and modi4 --- tools/h5dump/h5dump.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index 4cf3181..972d998 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -2740,10 +2740,12 @@ main(int argc, const char *argv[]) } } - if (argv[opt_ind][0] == '\\') - fname = &argv[opt_ind][1]; - else - fname = argv[opt_ind]; + if (argc <= opt_ind) { + error_msg(progname, "missing file name\n"); + usage(progname); + exit(EXIT_FAILURE); + } + fname = argv[opt_ind]; fid = h5tools_fopen(fname, driver, NULL, 0); -- cgit v0.12