commit 9491bb715d868c641ea2de62134ea28e37e58b51 from: Omar Polo date: Fri Feb 18 21:55:24 2022 UTC don't leak file descriptors commit - bf0e053b373293efee73f08763a50a9d4ec0f5f3 commit + 9491bb715d868c641ea2de62134ea28e37e58b51 blob - 31e9f32007eaba2a685339fcb5aff91596aa5bf0 blob + fde8ecfc1914f6f84451f491ebf27511d482d507 --- player_flac.c +++ player_flac.c @@ -118,4 +118,6 @@ play_flac(int fd) } FLAC__stream_decoder_delete(decoder); + + fclose(f); } blob - 22df939c86a81584737f7e3e162c8ccc9aac5717 blob + dde2aa7fba32e8e424d29c03237ab99aa53adb95 --- player_mad.c +++ player_mad.c @@ -175,15 +175,18 @@ play_mp3(int fd) if (fstat(fd, &stat) == -1) { log_warn("fstat"); - return; + goto end; } m = mmap(NULL, stat.st_size, PROT_READ, MAP_PRIVATE, fd, 0); if (m == MAP_FAILED) { log_warn("map failed"); - return; + goto end; } decode(m, stat.st_size); munmap(m, stat.st_size); + +end: + close(fd); } blob - 4f87ae3595c91d7db437efa7d7980af703af2b6d blob + 8028a6b40924aa0687192a18b6a338724f085c0e --- player_oggvorbis.c +++ player_oggvorbis.c @@ -86,4 +86,5 @@ play_oggvorbis(int fd) } ov_clear(&vf); + fclose(f); }