diff options
-rw-r--r-- | src/main.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -23,11 +23,13 @@ main(int argc, char *argv[]) } free(program_dir); n = db_games_find(games_dir, &games); - printf("%d games:\n", n); - for (i = 0; i < n; ++i) { - printf("\t%s\n", games[i]); - free(games[i]); + if (n > 0) { + printf("%d games:\n", n); + for (i = 0; i < n; ++i) { + printf("\t%s\n", games[i]); + free(games[i]); + } + free(games); } - free(games); return EXIT_SUCCESS; } |