E.g.:
$ cppcheck -q scm/abrt/ -I ./libreport/src/gtk-helpers/ -I ./libreport/src/include/ -I ./libreport/src/lib/ libreport/ [libreport/src/cli/cli-report.c:365]: (error) Resource leak: fd --- src/cli/cli-report.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/src/cli/cli-report.c b/src/cli/cli-report.c index f203fad..a1b51b2 100644 --- a/src/cli/cli-report.c +++ b/src/cli/cli-report.c @@ -318,18 +318,23 @@ static int run_report_editor(problem_data_t *problem_data) if (fclose(fp)) /* errno is set */ { perror_msg("Can't write '%s'", filename); + close(fd); return 2; }
// Start a text editor on the temporary file. if (launch_editor(filename) != 0) + { + close(fd); return 3; /* exit with error */ + }
// Read the file back and update the report from the file. fp = fopen(filename, "r"); if (!fp) /* errno is set */ { perror_msg("Can't open '%s' to read the crash report", filename); + close(fd); return 2; }
@@ -342,6 +347,7 @@ static int run_report_editor(problem_data_t *problem_data) { error_msg("Can't read '%s'", filename); fclose(fp); + close(fd); return 2; } text[size] = '\0'; @@ -362,6 +368,8 @@ static int run_report_editor(problem_data_t *problem_data) else puts(_("\nNo changes were detected in the report"));
+ close(fd); + return 0; }
crash-catcher@lists.fedorahosted.org