[JIRA:TT-1] Fix double eina_list_free 26/36226/1 accepted/tizen/tv/20150304.012002 submit/tizen_tv/20150303.232629
authorKim Tae Soo <taesoo46.kim@samsung.com>
Tue, 3 Mar 2015 23:22:36 +0000 (08:22 +0900)
committerKim Tae Soo <taesoo46.kim@samsung.com>
Tue, 3 Mar 2015 23:22:36 +0000 (08:22 +0900)
Change-Id: I3fd0a01a3531a646fc2cc676547e75dba2deca49
Signed-off-by: Kim Tae Soo <taesoo46.kim@samsung.com>
include/define.h
src/data/category_info.cpp
src/views/category-layout.cpp
src/views/category-songs-layout.cpp
src/views/song-layout.cpp

index 2d778b4..08ade04 100644 (file)
 #define SORT_BY_ALBUM_AZ "SORT_BY_ALBUM_AZ"
 #define SORT_BY_ALBUM_ZA "SORT_BY_ALBUM_ZA"
 
+/* for debugging */
+#define _eina_list_free(list) \
+{ \
+       if (!list) \
+               return; \
+       if (list->__magic != 0x98761237) { \
+               int *a = 0; \
+               *a = 1; \
+       } \
+       eina_list_free(list); \
+}
+
 #endif /* __DEFINE_H__ */
index 5de39ea..803d902 100644 (file)
@@ -19,6 +19,7 @@
 #include <Eina.h>
 #include "dbg.h"
 #include "i18n.h"
+#include "define.h"
 #include "category_info.h"
 
 
index a1b9134..2b188de 100644 (file)
@@ -933,26 +933,22 @@ void CCategoryLayout::m_EmptyLayout(bool sort_flag)
        }
 
        if (!sort_flag) {
-               if (m->catlist) {
+               if (m->catlist)
                        eina_list_free(m->catlist);
-                       m->catlist = NULL;
-               }
+               m->catlist = NULL;
        }
 
-       if (m->alblist) {
-               eina_list_free(m->alblist);
-               m->alblist = NULL;
-       }
+       // This value is just referenced from CCategoryInfo.
+       // So should not freed here.
+       m->alblist = NULL;
 
-       if (m->songlist) {
+       if (m->songlist)
                eina_list_free(m->songlist);
-               m->songlist = NULL;
-       }
+       m->songlist = NULL;
 
-       if (m->it_infolist) {
+       if (m->it_infolist)
                eina_list_free(m->it_infolist);
-               m->it_infolist = NULL;
-       }
+       m->it_infolist = NULL;
 
        m->total_duration = 0;
 
index 7d40d26..4ba866a 100644 (file)
@@ -919,8 +919,6 @@ bool CCategorySongsLayout::Create(CLayoutMgr *mgr, CCategoryLayout *parent)
        m->mhandle = mhandle;
        m->mgr = mgr;
        m->parent = parent;
-       m->catInfo = new CCategoryInfo;
-       m->albumInfo = new CAlbumInfo;
 
        Connect(layout, CATEGORY_SONGS_LAYOUT, TYPE_KEY_DOWN);
 
@@ -931,16 +929,6 @@ void CCategorySongsLayout::Destroy(void)
 {
        ASSERT(m);
 
-       if (m->catInfo->FlagCreate()) {
-               m->catInfo->Destroy();
-       }
-       delete m->catInfo;
-
-       if (m->albumInfo->FlagCreate()) {
-               m->albumInfo->Destroy();
-       }
-       delete m->albumInfo;
-
        m_RemoveFocusIdler();
        m_EmptySongList();
        CExtBaseLayout::Destroy();
@@ -958,22 +946,8 @@ void CCategorySongsLayout::SetParameter(EDepth depth, ESelectType selType, CCate
 
        m->depth = depth;
        m->selectType = selType;
-
-       if (m->catInfo->FlagCreate())
-               m->catInfo->Destroy();
-
-       if (m->albumInfo->FlagCreate())
-               m->albumInfo->Destroy();
-
-       if (catInfo && catInfo->FlagCreate()) {
-               m->catInfo->Create();
-               m->catInfo->Duplicate(catInfo);
-       }
-
-       if (albumInfo && albumInfo->FlagCreate()) {
-               m->albumInfo->Create();
-               m->albumInfo->Duplicate(albumInfo);
-       }
+       m->catInfo = catInfo;
+       m->albumInfo = albumInfo;
 }
 
 
index 3af52ea..fa48d2c 100644 (file)
@@ -404,7 +404,8 @@ void CSongLayout::m_EmptySongList(bool sort_flag)
                elm_genlist_clear(m->songlist);
 
        if (!sort_flag) {
-               eina_list_free(m->slist);
+               if (m->slist)
+                       eina_list_free(m->slist);
                m->slist = NULL;
        }