git: bffefaf3e1ef - main - pmcstudy: fix error handling
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 02 Jan 2022 09:52:31 UTC
The branch main has been updated by wma:
URL: https://cgit.FreeBSD.org/src/commit/?id=bffefaf3e1ef55e52c6428961925f8224c0a20b2
commit bffefaf3e1ef55e52c6428961925f8224c0a20b2
Author: sebastien.bini <sebastien.bini@stormshield.eu>
AuthorDate: 2021-12-14 10:42:17 +0000
Commit: Wojciech Macek <wma@FreeBSD.org>
CommitDate: 2022-01-02 09:51:07 +0000
pmcstudy: fix error handling
Close file descriptor in the correct way if no counters
are built into the application.
Obtained from: Stormshield
---
usr.sbin/pmcstudy/pmcstudy.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/usr.sbin/pmcstudy/pmcstudy.c b/usr.sbin/pmcstudy/pmcstudy.c
index 69d926a05e5d..6f5b6ba856a7 100644
--- a/usr.sbin/pmcstudy/pmcstudy.c
+++ b/usr.sbin/pmcstudy/pmcstudy.c
@@ -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;
}