From 15b8fdad9829e25c364f8b97e1d1cbb3ed8967cc Mon Sep 17 00:00:00 2001 From: Marc Date: Sun, 11 Sep 2022 14:20:29 +0200 Subject: [PATCH] fixed some segfault --- src/main.c | 13 ++++++++++--- src/steam.h | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main.c b/src/main.c index 1c4ae6c..44f7840 100644 --- a/src/main.c +++ b/src/main.c @@ -364,9 +364,15 @@ int main(int argc, char ** argv) { return EXIT_FAILURE; } - gamePaths = search_games(); + int searchStatus; + gamePaths = search_games(&searchStatus); int returnValue = EXIT_SUCCESS; + if(searchStatus == EXIT_FAILURE) { + printf("Error while looking up libraries, do you have steam installed ?"); + goto exit; + } + char * configFolder = g_build_filename(getHome(), MANAGER_FILES, NULL); if(access(configFolder, F_OK) != 0) { @@ -377,7 +383,7 @@ int main(int argc, char ** argv) { if(getuid() == 0) { printf("For the first please run without sudo\n"); returnValue = EXIT_FAILURE; - goto exit; + goto exit2; } else { //leading 0 == octal int i = g_mkdir_with_parents(configFolder, 0755); @@ -445,7 +451,8 @@ int main(int argc, char ** argv) { returnValue = EXIT_FAILURE; } -exit: +exit2: free(configFolder); +exit: return returnValue; } diff --git a/src/steam.h b/src/steam.h index c96cfe9..dedc2e7 100644 --- a/src/steam.h +++ b/src/steam.h @@ -43,7 +43,7 @@ const static char * GAMES_NAMES[] = { "Skyrim Special Edition", }; -GHashTable * search_games(); +GHashTable* search_games(int * status); int getGameIdFromAppId(u_int32_t id); #endif