aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRichard A. Kirian <rkirian@asu.edu>2011-11-29 13:54:08 -0800
committerThomas White <taw@physics.org>2012-02-22 15:27:42 +0100
commitb509b608b5d22a06d618f011eaae0c4ab6c8e610 (patch)
treea1d0f083021269b1b47e2ef87ab8021e93d7a701 /src
parent220f6796e49dc842750d674b744f0f00129ada05 (diff)
Fix possible seg fault in powder_plot
Diffstat (limited to 'src')
-rw-r--r--src/powder_plot.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/powder_plot.c b/src/powder_plot.c
index d31ce59c..bb3ace9e 100644
--- a/src/powder_plot.c
+++ b/src/powder_plot.c
@@ -884,7 +884,15 @@ int main(int argc, char *argv[])
}
- if ( is_stream(filename) ) {
+
+ /* need to check that the file even exists before moving on */
+ FILE * junk = fopen(filename,"r");
+ if ( junk == NULL ) {
+ ERROR("The file %s does not exist!\n",filename);
+ exit(1);
+ }
+
+ if ( is_stream(filename) == 1 ) {
file_type = FILE_STREAM;
fh = fopen(filename, "r");