Skip to content

Commit 000ba8c

Browse files
playlist: a better crash fix in pl_item_copy
1 parent 2b7e791 commit 000ba8c

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

include/deadbeef/deadbeef.h

+6
Original file line numberDiff line numberDiff line change
@@ -1078,6 +1078,12 @@ typedef struct {
10781078
DB_playItem_t * (*pl_item_alloc_init) (const char *fname, const char *decoder_id);
10791079
void (*pl_item_ref) (DB_playItem_t *it);
10801080
void (*pl_item_unref) (DB_playItem_t *it);
1081+
1082+
// Copy playlist item with metadata.
1083+
// NOTE: There's a behavior change from 1.9.6 to the next version:
1084+
// The older version was copying the previous/next pointers into the original linked lists (both main and search).
1085+
// This was required by some ancient version of deadbeef,
1086+
// but in the current one it causes a crash bug / data corruption under certain circumstances.
10811087
void (*pl_item_copy) (DB_playItem_t *out, DB_playItem_t *in);
10821088

10831089
// request lock for adding files to playlist

src/playlist.c

-8
Original file line numberDiff line numberDiff line change
@@ -1876,10 +1876,6 @@ pl_item_copy (playItem_t *out, playItem_t *it) {
18761876
out->endsample64 = it->endsample64;
18771877
out->shufflerating = it->shufflerating;
18781878
out->_duration = it->_duration;
1879-
out->next[PL_MAIN] = it->next[PL_MAIN];
1880-
out->prev[PL_MAIN] = it->prev[PL_MAIN];
1881-
out->next[PL_SEARCH] = it->next[PL_SEARCH];
1882-
out->prev[PL_SEARCH] = it->prev[PL_SEARCH];
18831879

18841880
for (DB_metaInfo_t *meta = it->meta; meta; meta = meta->next) {
18851881
pl_add_meta_copy (out, meta);
@@ -3886,10 +3882,6 @@ plt_copy_items (playlist_t *to, int iter, playlist_t *from, playItem_t *before,
38863882
if (items[i]) {
38873883
playItem_t *new_it = pl_item_alloc ();
38883884
pl_item_copy (new_it, items[i]);
3889-
new_it->next[PL_MAIN] = NULL;
3890-
new_it->prev[PL_MAIN] = NULL;
3891-
new_it->next[PL_SEARCH] = NULL;
3892-
new_it->prev[PL_SEARCH] = NULL;
38933885
pl_insert_item (after, new_it);
38943886
pl_item_unref (new_it);
38953887
after = new_it;

0 commit comments

Comments
 (0)