pmcstudy: fix error handling

Close file descriptor in the correct way if no counters
are built into the application.

Obtained from:		Stormshield
This commit is contained in:
sebastien.bini 2021-12-14 11:42:17 +01:00 committed by Wojciech Macek
parent d28d74de87
commit bffefaf3e1

View File

@ -2249,6 +2249,10 @@ process_file(char *filename)
if (filename == NULL) {
io = my_popen(command, "r", &pid_of_command);
if (io == NULL) {
printf("Can't popen the command %s\n", command);
return;
}
} else {
io = fopen(filename, "r");
if (io == NULL) {
@ -2261,8 +2265,10 @@ process_file(char *filename)
if (cnts == NULL) {
/* Nothing we can do */
printf("Nothing to do -- no counters built\n");
if (io) {
if (filename) {
fclose(io);
} else {
my_pclose(io, pid_of_command);
}
return;
}