bug fix - assigning address of local auto-variable to a function parameter 89/45689/1
authorSoohye Shin <soohye.shin@samsung.com>
Mon, 10 Aug 2015 10:13:14 +0000 (19:13 +0900)
committerSoohye Shin <soohye.shin@samsung.com>
Mon, 10 Aug 2015 10:13:14 +0000 (19:13 +0900)
Change-Id: I29dc07ca45250611b9d77ef86c0a6aa484414ae3
Signed-off-by: Soohye Shin <soohye.shin@samsung.com>
src/data/data_recent.c

index 38489a7..dc7b922 100644 (file)
@@ -252,9 +252,8 @@ static void _gallery_list_foreach(gpointer data, gpointer user_data)
        media_info_destroy(media);
 }
 
-static void _get_duration(int duration, char **str)
+static void _get_duration(int duration, char *str, size_t length)
 {
-       char buf[BUF_TITLE_MAX];
        int h, m, s, sec;
 
        sec = duration / 1000;
@@ -263,11 +262,9 @@ static void _get_duration(int duration, char **str)
        s = sec % 60;
 
        if (h)
-               snprintf(buf, sizeof(buf), "%d:%02d:%02d", h, m, s);
+               snprintf(str, length, "%d:%02d:%02d", h, m, s);
        else
-               snprintf(buf, sizeof(buf), "%d:%02d", m, s);
-
-       *str = buf;
+               snprintf(str, length, "%d:%02d", m, s);
 }
 
 static void _movie_list_foreach(gpointer data, gpointer user_data)
@@ -279,7 +276,7 @@ static void _movie_list_foreach(gpointer data, gpointer user_data)
        app_media_info *aminfo;
        media_info_h media;
        int r;
-       char *dur = NULL;
+       char dur[BUF_TITLE_MAX];
 
        if (!data || !user_data) {
                _ERR("Invalid arguement");
@@ -311,10 +308,10 @@ static void _movie_list_foreach(gpointer data, gpointer user_data)
        }
 
        if (aminfo->video && aminfo->video->duration)
-               _get_duration(aminfo->video->duration, &dur);
+               _get_duration(aminfo->video->duration, dur, sizeof(dur));
 
        di = _new_datamgr_item(aminfo->title, aminfo->thumbnail_path,
-                       dur ? dur : NULL, PACKAGE_MEDIAHUB, KEY_MEDIA,
+                       dur, PACKAGE_MEDIAHUB, KEY_MEDIA,
                        rdata->id, IMAGE_RECENT_ICON_MOVIE, 1, rdata->time);
        if (di)
                dm->list = eina_list_append(dm->list, di);