diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/playlist.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/apps/playlist.c b/apps/playlist.c index 7040c2a129..77e0ee4370 100644 --- a/apps/playlist.c +++ b/apps/playlist.c | |||
@@ -3894,7 +3894,7 @@ static int pl_save_update_control(struct playlist_info* playlist, | |||
3894 | char *tmpbuf, size_t tmpsize) | 3894 | char *tmpbuf, size_t tmpsize) |
3895 | { | 3895 | { |
3896 | int old_fd; | 3896 | int old_fd; |
3897 | int err; | 3897 | int err = 0; |
3898 | char c; | 3898 | char c; |
3899 | bool any_queued = false; | 3899 | bool any_queued = false; |
3900 | 3900 | ||
@@ -3915,8 +3915,8 @@ static int pl_save_update_control(struct playlist_info* playlist, | |||
3915 | playlist->control_fd = open(tmpbuf, O_CREAT|O_RDWR|O_TRUNC, 0666); | 3915 | playlist->control_fd = open(tmpbuf, O_CREAT|O_RDWR|O_TRUNC, 0666); |
3916 | if (playlist->control_fd < 0) | 3916 | if (playlist->control_fd < 0) |
3917 | { | 3917 | { |
3918 | close(old_fd); | 3918 | err = -3; |
3919 | return -3; | 3919 | goto error; |
3920 | } | 3920 | } |
3921 | 3921 | ||
3922 | /* Write out playlist filename */ | 3922 | /* Write out playlist filename */ |
@@ -3932,8 +3932,8 @@ static int pl_save_update_control(struct playlist_info* playlist, | |||
3932 | 3932 | ||
3933 | if (err <= 0) | 3933 | if (err <= 0) |
3934 | { | 3934 | { |
3935 | close(old_fd); | 3935 | err = -4; |
3936 | return -4; | 3936 | goto error; |
3937 | } | 3937 | } |
3938 | 3938 | ||
3939 | if (playlist->first_index > 0) | 3939 | if (playlist->first_index > 0) |
@@ -3964,8 +3964,10 @@ static int pl_save_update_control(struct playlist_info* playlist, | |||
3964 | index, playlist->last_insert_pos, | 3964 | index, playlist->last_insert_pos, |
3965 | tmpbuf, NULL, &seekpos); | 3965 | tmpbuf, NULL, &seekpos); |
3966 | if (err <= 0) | 3966 | if (err <= 0) |
3967 | return -5; | 3967 | { |
3968 | 3968 | err = -5; | |
3969 | goto error; | ||
3970 | } | ||
3969 | /* Update seek offset for the new control file. */ | 3971 | /* Update seek offset for the new control file. */ |
3970 | playlist->indices[index] &= ~PLAYLIST_SEEK_MASK; | 3972 | playlist->indices[index] &= ~PLAYLIST_SEEK_MASK; |
3971 | playlist->indices[index] |= seekpos; | 3973 | playlist->indices[index] |= seekpos; |
@@ -3980,7 +3982,10 @@ static int pl_save_update_control(struct playlist_info* playlist, | |||
3980 | err = update_control_unlocked(playlist, PLAYLIST_COMMAND_FLAGS, | 3982 | err = update_control_unlocked(playlist, PLAYLIST_COMMAND_FLAGS, |
3981 | PLAYLIST_FLAG_MODIFIED, 0, NULL, NULL, NULL); | 3983 | PLAYLIST_FLAG_MODIFIED, 0, NULL, NULL, NULL); |
3982 | if (err <= 0) | 3984 | if (err <= 0) |
3983 | return -6; | 3985 | { |
3986 | err = -6; | ||
3987 | goto error; | ||
3988 | } | ||
3984 | } | 3989 | } |
3985 | else | 3990 | else |
3986 | { | 3991 | { |
@@ -4006,7 +4011,12 @@ static int pl_save_update_control(struct playlist_info* playlist, | |||
4006 | 4011 | ||
4007 | playlist->control_fd = open(playlist->control_filename, O_RDWR); | 4012 | playlist->control_fd = open(playlist->control_filename, O_RDWR); |
4008 | playlist->control_created = (playlist->control_fd >= 0); | 4013 | playlist->control_created = (playlist->control_fd >= 0); |
4014 | |||
4009 | return 0; | 4015 | return 0; |
4016 | |||
4017 | error: | ||
4018 | close(old_fd); | ||
4019 | return err; | ||
4010 | } | 4020 | } |
4011 | 4021 | ||
4012 | int playlist_save(struct playlist_info* playlist, char *filename) | 4022 | int playlist_save(struct playlist_info* playlist, char *filename) |