Skip to content

Commit

Permalink
playlist: a better crash fix in pl_item_copy
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksiy-Yakovenko committed Nov 24, 2024
1 parent 2b7e791 commit 000ba8c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 6 additions & 0 deletions include/deadbeef/deadbeef.h
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,12 @@ typedef struct {
DB_playItem_t * (*pl_item_alloc_init) (const char *fname, const char *decoder_id);
void (*pl_item_ref) (DB_playItem_t *it);
void (*pl_item_unref) (DB_playItem_t *it);

// Copy playlist item with metadata.
// NOTE: There's a behavior change from 1.9.6 to the next version:
// The older version was copying the previous/next pointers into the original linked lists (both main and search).
// This was required by some ancient version of deadbeef,
// but in the current one it causes a crash bug / data corruption under certain circumstances.
void (*pl_item_copy) (DB_playItem_t *out, DB_playItem_t *in);

// request lock for adding files to playlist
Expand Down
8 changes: 0 additions & 8 deletions src/playlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -1876,10 +1876,6 @@ pl_item_copy (playItem_t *out, playItem_t *it) {
out->endsample64 = it->endsample64;
out->shufflerating = it->shufflerating;
out->_duration = it->_duration;
out->next[PL_MAIN] = it->next[PL_MAIN];
out->prev[PL_MAIN] = it->prev[PL_MAIN];
out->next[PL_SEARCH] = it->next[PL_SEARCH];
out->prev[PL_SEARCH] = it->prev[PL_SEARCH];

for (DB_metaInfo_t *meta = it->meta; meta; meta = meta->next) {
pl_add_meta_copy (out, meta);
Expand Down Expand Up @@ -3886,10 +3882,6 @@ plt_copy_items (playlist_t *to, int iter, playlist_t *from, playItem_t *before,
if (items[i]) {
playItem_t *new_it = pl_item_alloc ();
pl_item_copy (new_it, items[i]);
new_it->next[PL_MAIN] = NULL;
new_it->prev[PL_MAIN] = NULL;
new_it->next[PL_SEARCH] = NULL;
new_it->prev[PL_SEARCH] = NULL;
pl_insert_item (after, new_it);
pl_item_unref (new_it);
after = new_it;
Expand Down

0 comments on commit 000ba8c

Please sign in to comment.