Commit d1df71eb authored by Max Kellermann's avatar Max Kellermann

playlist: fix FILE* leak in appendSongToStoredPlaylistByPath()

When an error occurs after the file has been opened, the function will never close the FILE object.
parent 54c8e3da
...@@ -301,9 +301,11 @@ int appendSongToStoredPlaylistByPath(int fd, const char *utf8path, Song *song) ...@@ -301,9 +301,11 @@ int appendSongToStoredPlaylistByPath(int fd, const char *utf8path, Song *song)
if (fstat(fileno(file), &st) < 0) { if (fstat(fileno(file), &st) < 0) {
commandError(fd, ACK_ERROR_NO_EXIST, "could not stat file " commandError(fd, ACK_ERROR_NO_EXIST, "could not stat file "
"\"%s\": %s", path_max_tmp, strerror(errno)); "\"%s\": %s", path_max_tmp, strerror(errno));
while (fclose(file) != 0 && errno == EINTR);
return -1; return -1;
} }
if (st.st_size >= ((MPD_PATH_MAX+1) * playlist_max_length)) { if (st.st_size >= ((MPD_PATH_MAX+1) * playlist_max_length)) {
while (fclose(file) != 0 && errno == EINTR);
commandError(fd, ACK_ERROR_PLAYLIST_MAX, commandError(fd, ACK_ERROR_PLAYLIST_MAX,
"playlist is at the max size"); "playlist is at the max size");
return -1; return -1;
......
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