From 01aaf80f8dbfddd58399114ee27e261d5c601c59 Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Mon, 20 Jan 2014 21:53:25 +0100 Subject: fixed playlist loaders refcounting bug --- playlist.c | 12 ++++++------ plugins/gtkui/actionhandlers.c | 3 --- plugins/m3u/m3u.c | 18 ------------------ 3 files changed, 6 insertions(+), 27 deletions(-) diff --git a/playlist.c b/playlist.c index 4aa4fab6..27330ca7 100644 --- a/playlist.c +++ b/playlist.c @@ -2487,6 +2487,9 @@ plt_load_int (int visibility, playlist_t *plt, playItem_t *after, const char *fn fclose (fp); } trace ("plt_load: success\n"); + if (last_added) { + pl_item_unref (last_added); + } return last_added; load_fail: plt_clear (plt); @@ -2494,6 +2497,9 @@ load_fail: if (fp) { fclose (fp); } + if (last_added) { + pl_item_unref (last_added); + } return last_added; } @@ -2522,9 +2528,6 @@ pl_load_all (void) { playlist_t *plt = plt_get_for_idx (0); playItem_t *it = plt_load (plt, NULL, defpl, NULL, NULL, NULL); - if (it) { - pl_item_unref (it); - } plt_unref (plt); return 0; } @@ -2550,9 +2553,6 @@ pl_load_all (void) { playlist_t *plt = plt_get_curr (); playItem_t *trk = plt_load (plt, NULL, path, NULL, NULL, NULL); - if (trk) { - pl_item_unref (trk); - } char conf[100]; snprintf (conf, sizeof (conf), "playlist.cursor.%d", i); plt->current_row[PL_MAIN] = deadbeef->conf_get_int (conf, -1); diff --git a/plugins/gtkui/actionhandlers.c b/plugins/gtkui/actionhandlers.c index e6330973..6e3934e4 100644 --- a/plugins/gtkui/actionhandlers.c +++ b/plugins/gtkui/actionhandlers.c @@ -666,9 +666,6 @@ load_playlist_thread (void *data) { deadbeef->plt_clear (plt); int abort = 0; DB_playItem_t *it = deadbeef->plt_load2 (0, plt, NULL, fname, &abort, NULL, NULL); - if (it) { - deadbeef->pl_item_unref (it); - } deadbeef->plt_save_config (plt); deadbeef->plt_add_files_end (plt, 0); } diff --git a/plugins/m3u/m3u.c b/plugins/m3u/m3u.c index bedaff6f..c3e76cc2 100644 --- a/plugins/m3u/m3u.c +++ b/plugins/m3u/m3u.c @@ -215,9 +215,6 @@ load_m3u (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname, int *pab after = it; } if (pabort && *pabort) { - if (after) { - deadbeef->pl_item_ref (after); - } free (membuffer); return after; } @@ -226,9 +223,6 @@ load_m3u (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname, int *pab break; } } - if (after) { - deadbeef->pl_item_ref (after); - } trace ("leave pl_insert_m3u\n"); free (membuffer); return after; @@ -325,9 +319,6 @@ load_pls (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname, int *pab after = it; } if (pabort && *pabort) { - if (after) { - deadbeef->pl_item_ref (after); - } free (buffer); return after; } @@ -365,9 +356,6 @@ load_pls (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname, int *pab after = it; } if (pabort && *pabort) { - if (after) { - deadbeef->pl_item_ref (after); - } free (buffer); return after; } @@ -404,9 +392,6 @@ load_pls (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname, int *pab after = it; } if (pabort && *pabort) { - if (after) { - deadbeef->pl_item_ref (after); - } free (buffer); return after; } @@ -448,9 +433,6 @@ load_pls (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname, int *pab after = it; } } - if (after) { - deadbeef->pl_item_ref (after); - } free (buffer); return after; } -- cgit v1.2.3