Skip to content

Commit d12d885

Browse files
committed
add missing pclose()
Signed-off-by: Michel-FK <[email protected]>
1 parent 936c912 commit d12d885

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

fk_instant_play.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,24 @@
4242
/* Handler for SIGUSR1, caused by closing the console */
4343
static void handle_sigusr1(int signal)
4444
{
45+
FILE *fp;
46+
4547
printf("Caught signal USR1(%d)\n", signal);
4648

4749
/* Exit menu if it was launched */
4850
FK_EndMenu();
4951

5052
/* Send command to cancel any previously scheduled powerdown */
51-
if (popen(SHELL_CMD_CANCEL_SCHED_POWERDOWN, "r") == NULL)
53+
fp = popen(SHELL_CMD_CANCEL_SCHED_POWERDOWN, "r");
54+
if (fp == NULL)
5255
{
5356
/* Countdown is still ticking, so better do nothing
5457
than start writing and get interrupted!
5558
*/
5659
printf("Failed to cancel scheduled shutdown\n");
5760
exit(0);
5861
}
62+
pclose(fp);
5963

6064
/* Perform Instant Play save and shutdown */
6165
execlp(SHELL_CMD_POWERDOWN, SHELL_CMD_POWERDOWN);

fk_menu.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ static void init_menu_system_values(void)
502502
volume_percentage = 50; ///wrong value: setting default to 50
503503
}
504504
else{
505+
pclose(fp);
505506
fgets(res, sizeof(res)-1, fp);
506507

507508
/// Check if Volume is a number (at least the first char)
@@ -523,6 +524,7 @@ static void init_menu_system_values(void)
523524
brightness_percentage = 50; ///wrong value: setting default to 50
524525
}
525526
else{
527+
pclose(fp);
526528
fgets(res, sizeof(res)-1, fp);
527529

528530
/// Check if brightness is a number (at least the first char)
@@ -1011,6 +1013,7 @@ int FK_RunMenu(SDL_Surface *screen)
10111013
if (fp == NULL) {
10121014
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
10131015
}
1016+
pclose(fp);
10141017

10151018
/// ------ Refresh screen ------
10161019
screen_refresh = 1;
@@ -1029,6 +1032,8 @@ int FK_RunMenu(SDL_Surface *screen)
10291032
if (fp == NULL) {
10301033
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
10311034
}
1035+
pclose(fp);
1036+
10321037
/// ------ Refresh screen ------
10331038
screen_refresh = 1;
10341039
} else
@@ -1085,6 +1090,8 @@ int FK_RunMenu(SDL_Surface *screen)
10851090
if (fp == NULL) {
10861091
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
10871092
}
1093+
pclose(fp);
1094+
10881095
/// ------ Refresh screen ------
10891096
screen_refresh = 1;
10901097
} else
@@ -1102,6 +1109,8 @@ int FK_RunMenu(SDL_Surface *screen)
11021109
if (fp == NULL) {
11031110
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
11041111
}
1112+
pclose(fp);
1113+
11051114
/// ------ Refresh screen ------
11061115
screen_refresh = 1;
11071116
} else
@@ -1194,6 +1203,7 @@ int FK_RunMenu(SDL_Surface *screen)
11941203
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
11951204
}
11961205
else{
1206+
pclose(fp);
11971207
usb_sharing = !usb_sharing;
11981208
}*/
11991209

@@ -1294,7 +1304,7 @@ int FK_RunMenu(SDL_Surface *screen)
12941304
if (fp == NULL) {
12951305
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
12961306
}
1297-
1307+
pclose(fp);
12981308
return MENU_RETURN_EXIT;
12991309
}
13001310
else{

0 commit comments

Comments
 (0)