Skip to content

Commit 152bae7

Browse files
committed
add missing pclose()
Signed-off-by: Vincent-FK <[email protected]>
1 parent 473e951 commit 152bae7

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

RetroFE/Source/Execute/Launcher.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ bool Launcher::run(std::string collection, Item *collectionItem)
4747
std::string matchedExtension;
4848
std::string args;
4949
bool res = true;
50+
FILE *fp;
5051

5152
std::string launcherFile = Utils::combinePath( Configuration::absolutePath, "collections", collectionItem->collectionInfo->name, "launchers", collectionItem->name + ".conf" );
5253
std::ifstream launcherStream( launcherFile.c_str( ) );
@@ -120,7 +121,10 @@ bool Launcher::run(std::string collection, Item *collectionItem)
120121
collection);
121122

122123
/* Restart audio amp */
123-
popen(SHELL_CMD_TURN_AMPLI_ON, "r");
124+
fp = popen(SHELL_CMD_TURN_AMPLI_ON, "r");
125+
if (fp != NULL) {
126+
pclose(fp);
127+
}
124128

125129
/* Execute game */
126130
if(!execute(executablePath, args, currentDirectory))
@@ -130,7 +134,10 @@ bool Launcher::run(std::string collection, Item *collectionItem)
130134
}
131135

132136
/* Stop audio amp */
133-
popen(SHELL_CMD_TURN_AMPLI_OFF, "r");
137+
fp = popen(SHELL_CMD_TURN_AMPLI_OFF, "r");
138+
if (fp != NULL) {
139+
pclose(fp);
140+
}
134141

135142
/* Restore stored PID */
136143
char shellCmd[20];

RetroFE/Source/Menu/MenuMode.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ void MenuMode::init_menu_system_values(){
399399
volume_percentage = 50; ///wrong value: setting default to 50
400400
}
401401
else{
402+
pclose(fp);
402403
fgets(res, sizeof(res)-1, fp);
403404

404405
/// Check if Volume is a number (at least the first char)
@@ -419,6 +420,7 @@ void MenuMode::init_menu_system_values(){
419420
brightness_percentage = 50; ///wrong value: setting default to 50
420421
}
421422
else{
423+
pclose(fp);
422424
fgets(res, sizeof(res)-1, fp);
423425

424426
/// Check if brightness is a number (at least the first char)
@@ -846,6 +848,8 @@ int MenuMode::launch( )
846848
fp = popen(shell_cmd, "r");
847849
if (fp == NULL) {
848850
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
851+
} else {
852+
pclose(fp);
849853
}
850854

851855
/// ------ Refresh screen ------
@@ -862,6 +866,8 @@ int MenuMode::launch( )
862866
fp = popen(shell_cmd, "r");
863867
if (fp == NULL) {
864868
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
869+
} else {
870+
pclose(fp);
865871
}
866872
/// ------ Refresh screen ------
867873
screen_refresh = 1;
@@ -907,6 +913,8 @@ int MenuMode::launch( )
907913
fp = popen(shell_cmd, "r");
908914
if (fp == NULL) {
909915
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
916+
} else {
917+
pclose(fp);
910918
}
911919
/// ------ Refresh screen ------
912920
screen_refresh = 1;
@@ -922,6 +930,8 @@ int MenuMode::launch( )
922930
fp = popen(shell_cmd, "r");
923931
if (fp == NULL) {
924932
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
933+
} else {
934+
pclose(fp);
925935
}
926936
/// ------ Refresh screen ------
927937
screen_refresh = 1;
@@ -1001,6 +1011,7 @@ int MenuMode::launch( )
10011011
}
10021012
else{
10031013
usb_sharing = !usb_sharing;
1014+
pclose(fp);
10041015
}*/
10051016

10061017
bool res = Utils::executeRawPath(usb_sharing?SHELL_CMD_USB_UNMOUNT:SHELL_CMD_USB_MOUNT);
@@ -1091,6 +1102,8 @@ int MenuMode::launch( )
10911102
fp = popen(shell_cmd, "r");
10921103
if (fp == NULL) {
10931104
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
1105+
} else {
1106+
pclose(fp);
10941107
}
10951108

10961109
return MENU_RETURN_EXIT;

RetroFE/Source/Sound/Sound.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,16 @@ Sound::~Sound()
4848

4949
void Sound::play()
5050
{
51+
FILE *fp;
52+
5153
//printf("%s\n", __func__);
5254
SDL_RemoveTimer(idTimer);
5355
if(!ampliStarted){
54-
popen(SHELL_CMD_TURN_AMPLI_ON, "r");
55-
ampliStarted = 1;
56+
fp = popen(SHELL_CMD_TURN_AMPLI_ON, "r");
57+
if (fp != NULL) {
58+
ampliStarted = 1;
59+
pclose(fp);
60+
}
5661
}
5762

5863
if(chunk_)
@@ -64,9 +69,14 @@ void Sound::play()
6469

6570
uint32_t Sound::turnOffAmpli(uint32_t interval, void *param)
6671
{
72+
FILE *fp;
73+
6774
//printf("%s\n", __func__);
68-
popen(SHELL_CMD_TURN_AMPLI_OFF, "r");
69-
ampliStarted = 0;
75+
fp = popen(SHELL_CMD_TURN_AMPLI_OFF, "r");
76+
if (fp != NULL) {
77+
ampliStarted = 0;
78+
pclose(fp);
79+
}
7080
return 0;
7181
}
7282

0 commit comments

Comments
 (0)