diff options
author | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2021-03-16 09:38:37 (EDT) |
---|---|---|
committer | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2021-03-16 09:48:51 (EDT) |
commit | 60abe24450a8d02b0a0f85c40190f26472fb5ab8 (patch) | |
tree | dd1bda39cb5495f245dbd72bbc2673151ae1d942 /src | |
parent | bd931017c1843f9ae24ce082ab41c43cb57428e8 (diff) | |
download | dodge-balls-60abe24450a8d02b0a0f85c40190f26472fb5ab8.zip dodge-balls-60abe24450a8d02b0a0f85c40190f26472fb5ab8.tar.gz dodge-balls-60abe24450a8d02b0a0f85c40190f26472fb5ab8.tar.bz2 |
db_games_find(): Check scandir() return value
Fixes a bad calloc() if the games directory is empty or not found.
Diffstat (limited to 'src')
-rw-r--r-- | src/game.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -37,6 +37,12 @@ db_games_find(const char *games_dir, char ***games) int i; n = scandir(games_dir, &entries, &_db_game_is_dir, alphasort); + if (n < 0) { + db_err("Failed to scan games directory"); + return -1; + } else if (n == 0) { + return 0; + } *games = calloc(n, sizeof(**games)); if (*games == NULL) { |