diff options
author | Jan200101 <sentrycraft123@gmail.com> | 2021-04-24 17:30:20 +0200 |
---|---|---|
committer | Jan200101 <sentrycraft123@gmail.com> | 2021-04-24 17:30:20 +0200 |
commit | 67d5d1b742584ffeb9859eb7b92a41e0d365622d (patch) | |
tree | c9903671425f1287ed93b6a3ee735a28b3197968 /src | |
parent | 6867c3f51eb7702a1379a66f12627b35924edbed (diff) | |
download | polecat-67d5d1b742584ffeb9859eb7b92a41e0d365622d.tar.gz polecat-67d5d1b742584ffeb9859eb7b92a41e0d365622d.zip |
update allocsize with the largest size we might possibly need
Diffstat (limited to 'src')
-rw-r--r-- | src/lutris.c | 8 |
1 files 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)); |