From 52f8abc09b0d97608ba9d5b57ea96c48a1390384 Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Sun, 16 May 2021 01:22:08 +0200 Subject: add NULL checks --- src/lutris.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lutris.c b/src/lutris.c index 1e4df0d..0dd999b 100644 --- a/src/lutris.c +++ b/src/lutris.c @@ -36,12 +36,15 @@ COMMAND(lutris, search) // argv being modifyable is not always a given so lets // lets make a mutable copy char* str = strdup(argv[1]); + if (!str) return 1; + // in the case we need to do replacing we allocate more // since we'll free in anyway // the smallest strlen can return is 0 the longest // escapeString can return is strlen*3 size_t allocsize = strlen(str) * 3; str = realloc(str, allocsize); + if (!str) return 1; lutris_escapeString(str, allocsize); char* url = malloc(strlen(GAME_SEARCH_API) + strlen(str)); sprintf(url, GAME_SEARCH_API, str); @@ -87,12 +90,15 @@ COMMAND(lutris, list) // argv being modifyable is not always a given so lets // lets make a mutable copy char* str = strdup(argv[1]); + if (!str) return 1; + // in the case we need to do replacing we allocate more // since we'll free in anyway // the smallest strlen can return is 0 the longest // escapeString can return is strlen*3 size_t allocsize = strlen(str) * 3; str = realloc(str, allocsize); + if (!str) return 1; lutris_escapeString(str, allocsize); char* url = malloc(strlen(GAME_INSTALLER_API) + strlen(str)); sprintf(url, GAME_INSTALLER_API, str); -- cgit v1.2.3