Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7820b0c

Browse files
authored
fix: handle fopen failure in call graph output paths (#117)
1 parent 14549eb commit 7820b0c

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/cscout.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2401,6 +2401,10 @@ graph_txt_page(FILE *fo, void (*graph_fun)(GraphDisplay *))
24012401
char *outfile;
24022402
if (swill_getargs("i(output)s(outfile)", &output, &outfile) && output && strlen(outfile)) {
24032403
FILE *ofile = fopen(outfile, "w+");
2404+
if (ofile == NULL) {
2405+
html_perror(fo, "Unable to open " + string(outfile) + " for writing");
2406+
return 0;
2407+
}
24042408
GDTxt gdout(ofile);
24052409
graph_fun(&gdout);
24062410
fclose(ofile);
@@ -2505,6 +2509,10 @@ produce_call_graphs(const vector <string> &call_graphs)
25052509
}
25062510

25072511
FILE *target = fopen(split_base_and_opts[0].c_str() , "w+");
2512+
if (target == NULL) {
2513+
perror(split_base_and_opts[0].c_str());
2514+
continue;
2515+
}
25082516
string base = split_base_and_opts[0];
25092517
GDTxt gd(target);
25102518
// Disable swill

0 commit comments

Comments
 (0)