Commit 5ce625ea authored by Max Kellermann's avatar Max Kellermann

stored_playlist: don't close NULL file on error

spl_append_song() can crash when fopen() fails, because it attempts to close the invalid file handle (NULL) in the error handler.
parent 85658965
......@@ -379,12 +379,8 @@ spl_append_song(const char *utf8path, struct song *song)
while (!(file = fopen(path_fs, "a")) && errno == EINTR);
g_free(path_fs);
if (file == NULL) {
int save_errno = errno;
while (fclose(file) != 0 && errno == EINTR);
errno = save_errno;
if (file == NULL)
return PLAYLIST_RESULT_ERRNO;
}
if (fstat(fileno(file), &st) < 0) {
int save_errno = errno;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment