From 67d5d1b742584ffeb9859eb7b92a41e0d365622d Mon Sep 17 00:00:00 2001 From: Jan200101 Date: Sat, 24 Apr 2021 17:30:20 +0200 Subject: update allocsize with the largest size we might possibly need --- src/lutris.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lutris.c b/src/lutris.c index bd2a2d4..7d663c0 100644 --- a/src/lutris.c +++ b/src/lutris.c @@ -34,7 +34,9 @@ COMMAND(lutris, search) char* str = strdup(argv[1]); // in the case we need to do replacing we allocate more // since we'll free in anyway - size_t allocsize = strlen(str) * 2; + // 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); lutris_escapeString(str, allocsize); char* url = malloc(strlen(GAME_SEARCH_API) + strlen(str)); @@ -83,7 +85,9 @@ COMMAND(lutris, list) char* str = strdup(argv[1]); // in the case we need to do replacing we allocate more // since we'll free in anyway - size_t allocsize = strlen(str) * 2; + // 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); lutris_escapeString(str, allocsize); char* url = malloc(strlen(GAME_INSTALLER_API) + strlen(str)); -- cgit v1.2.3