Skip to content

Commit 2472ab6

Browse files
Richard Drinkwaterabower-amd
authored andcommitted
SWPTP-1597: ensure stats file in /proc is closed after performing read
1 parent ecf82be commit 2472ab6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/sfptpd_misc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,10 @@ int sfptpd_find_running_programs(struct sfptpd_prog *others)
114114
stream = fopen(path, "r");
115115
if (stream == NULL)
116116
goto next_process;
117-
if (fscanf(stream, "%*d %*s %c", &status) != 1)
118-
goto next_process;
117+
res = fscanf(stream, "%*d %*s %c", &status);
119118
fclose(stream);
119+
if (res != 1)
120+
goto next_process;
120121
if (strchr("ZXx", status))
121122
goto next_process;
122123

0 commit comments

Comments
 (0)