Skip to content

Commit 6e9a4d6

Browse files
committed
If one fopen() fails, then the second fopen() can fail too. Make sure to handle that.
1 parent a32c3b4 commit 6e9a4d6

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/emc/rs274ngc/rs274ngc_pre.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,6 +1953,13 @@ int Interp::save_parameters(const char *filename, //!< name of file to writ
19531953
infile = fopen(filename, "r");
19541954
if(!infile)
19551955
infile = fopen("/dev/null", "r");
1956+
if(!infile) {
1957+
// If we can't open the 'filename', we may not be able to open "/dev/null"
1958+
// either. If so, print an error, close 'outfile' and continue.
1959+
perror("Interp::save_parameters(): fopen(/dev/null)");
1960+
fclose(outfile);
1961+
return INTERP_OK;
1962+
}
19561963

19571964
k = 0;
19581965
index = 0;

0 commit comments

Comments
 (0)