Coverity Issue Fix 20/153320/2
authorHaejeong Kim <backto.kim@samsung.com>
Thu, 28 Sep 2017 08:47:44 +0000 (17:47 +0900)
committerHaejeong Kim <backto.kim@samsung.com>
Thu, 28 Sep 2017 08:58:00 +0000 (17:58 +0900)
Change-Id: I54eec93fc513692bde3df0030f2841d23fff0afe

formats/ffmpeg/mm_file_format_ffmpeg.c
formats/ffmpeg/mm_file_format_frame.c
mm_file.c
packaging/libmm-fileinfo.spec
utils/mm_file_util_tag.c

index 493ab7a..4bf8001 100755 (executable)
@@ -383,6 +383,7 @@ int mmfile_format_read_stream_ffmpg(MMFileFormatContext *formatContext)
 
        MMFileFormatStream  *videoStream = NULL;
        MMFileFormatStream  *audioStream = NULL;
+       unsigned int i = 0;
        int ret = 0;
 
        if (NULL == formatContext || NULL == formatContext->privateFormatData) {
@@ -425,7 +426,6 @@ int mmfile_format_read_stream_ffmpg(MMFileFormatContext *formatContext)
        formatContext->videoTotalTrackNum = 0;
        formatContext->audioTotalTrackNum = 0;
 
-       unsigned int i = 0;
        for (i = 0; i < pFormatCtx->nb_streams; i++) {
                if (pFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
                        if (formatContext->videoStreamId == -1) {
index 931eb77..46c0346 100755 (executable)
@@ -388,6 +388,12 @@ static int __mmfile_get_frame(AVFormatContext *pFormatCtx, int64_t timestamp, bo
        AVCodec *pVideoCodec = NULL;
        AVFrame *pFrame = NULL;
        AVPacket packet;
+       AVStream *pStream = NULL;
+       double duration = 0;
+       int64_t tmpPts = 0;
+#ifdef __MMFILE_TEST_MODE__
+       int idx = 0;
+#endif
 
        /* Retrieve stream information */
        if (avformat_find_stream_info(pFormatCtx, NULL) < 0) {
@@ -462,8 +468,8 @@ static int __mmfile_get_frame(AVFormatContext *pFormatCtx, int64_t timestamp, bo
        }
 
        /* Seeking */
-       AVStream *pStream = pFormatCtx->streams[videoStream];
-       double duration = (double) pFormatCtx->duration / AV_TIME_BASE;
+       pStream = pFormatCtx->streams[videoStream];
+       duration = (double) pFormatCtx->duration / AV_TIME_BASE;
 #if 0
        if (duration <= 0) {
                double tmpDuration = 0.0;
@@ -490,10 +496,6 @@ static int __mmfile_get_frame(AVFormatContext *pFormatCtx, int64_t timestamp, bo
                av_seek_frame(pFormatCtx, -1, pos, AVSEEK_FLAG_BACKWARD);
 
        /* Reading Data */
-       int64_t tmpPts = 0;
-#ifdef __MMFILE_TEST_MODE__
-       int idx = 0;
-#endif
 
        av_init_packet(&packet);
 
index 28ea7a2..c2e9385 100755 (executable)
--- a/mm_file.c
+++ b/mm_file.c
@@ -435,7 +435,7 @@ _info_set_attr_media(mmf_attrs_t *attrs, MMFileFormatContext *formatContext)
        }
 
        /*commit attrs*/
-       ret = mmf_attrs_commit((MMHandleType)hattrs);
+       mmf_attrs_commit((MMHandleType)hattrs);
 
        return ret;
 }
index a8aa9d1..8d2b109 100755 (executable)
@@ -1,6 +1,6 @@
 Name:      libmm-fileinfo
 Summary:    Media Fileinfo
-Version:    0.6.69
+Version:    0.6.70
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
index 81c7dbc..fa7efd2 100755 (executable)
@@ -247,37 +247,37 @@ static int GetStringFromTextTagBox(MMFileFormatContext *formatContext, MMFileIOH
        switch (eTag) {
                case eMMFILE_3GP_TAG_TITLE: {
                                if (!formatContext->title) {
-                                       formatContext->title = temp_text;
+                                       formatContext->title = g_strdup(temp_text);
                                }
                                break;
                        }
                case eMMFILE_3GP_TAG_CAPTION: {
                                if (!formatContext->description) {
-                                       formatContext->description = temp_text;
+                                       formatContext->description = g_strdup(temp_text);
                                }
                                break;
                        }
                case eMMFILE_3GP_TAG_COPYRIGHT: {
                                if (!formatContext->copyright) {
-                                       formatContext->copyright = temp_text;
+                                       formatContext->copyright = g_strdup(temp_text);
                                }
                                break;
                        }
                case eMMFILE_3GP_TAG_PERFORMER: {
                                if (!formatContext->artist) {
-                                       formatContext->artist = temp_text;
+                                       formatContext->artist = g_strdup(temp_text);
                                }
                                break;
                        }
                case eMMFILE_3GP_TAG_AUTHOR: {
                                if (!formatContext->author) {
-                                       formatContext->author = temp_text;
+                                       formatContext->author = g_strdup(temp_text);
                                }
                                break;
                        }
                case eMMFILE_3GP_TAG_GENRE: {
                                if (!formatContext->genre) {
-                                       formatContext->genre = temp_text;
+                                       formatContext->genre = g_strdup(temp_text);
                                }
                                break;
                        }
@@ -291,6 +291,8 @@ static int GetStringFromTextTagBox(MMFileFormatContext *formatContext, MMFileIOH
        texttag.text = NULL;
        mmfile_seek(fp, basic_header->start_offset + basic_header->size, SEEK_SET);
 
+       _FREE_EX(temp_text);
+
        return MMFILE_UTIL_SUCCESS;
 
 exception:
@@ -391,9 +393,10 @@ static int GetAlbumFromAlbumTagBox(MMFileFormatContext *formatContext, MMFileIOH
                        temp_text = mmfile_strdup((const char *)albumbox.albumtile);
                }
 
-               if (!formatContext->album) {
+               if (!formatContext->album)
                        formatContext->album = temp_text;
-               }
+               else
+                       _FREE_EX(temp_text);
 
                debug_msg(RELEASE, "formatContext->album=%s, strlen=%d\n", formatContext->album, strlen(formatContext->album));
        }
@@ -1910,6 +1913,8 @@ EXPORT_API int MMFileUtilGetMetaDataFromMP4(MMFileFormatContext *formatContext)
        int readed;
        unsigned long long chunk_size = 0;
        long long moov_end = 0;
+       MMFILE_MP4_BASIC_BOX_HEADER basic_header = {0, };
+       int junk_counter = 0;
 
        ret = mmfile_open(&fp, formatContext->uriFileName, MMFILE_RDONLY);
        if (ret == MMFILE_UTIL_FAIL) {
@@ -1917,10 +1922,8 @@ EXPORT_API int MMFileUtilGetMetaDataFromMP4(MMFileFormatContext *formatContext)
                goto exit;
        }
 
-       MMFILE_MP4_BASIC_BOX_HEADER basic_header = {0, };
        basic_header.start_offset = mmfile_tell(fp);
 
-       int junk_counter = 0;
        if (g_junk_counter_limit == 0)
                g_junk_counter_limit = GetJunkCounterLimit();
 
@@ -2831,6 +2834,8 @@ bool mm_file_id3tag_parse_v223(AvFileContentInfo *pInfo, unsigned char *buffer)
                                        debug_msg(RELEASE, "this text string(%s) encoded by ISO-8859-1 encodingOffSet(%d)\n", CompTmp, encodingOffSet);
                                }
 
+                               if (pExtContent)        _FREE_EX(pExtContent);
+
                                if (encodingOffSet < purelyFramelen) {
                                        realCpyFrameNum = purelyFramelen - encodingOffSet;
                                        pExtContent = mmfile_malloc(realCpyFrameNum + 3);
@@ -3456,6 +3461,8 @@ bool mm_file_id3tag_parse_v224(AvFileContentInfo *pInfo, unsigned char *buffer)
                                        }
                                }
 
+                               if (pExtContent)        _FREE_EX(pExtContent);
+
                                if (encodingOffSet < purelyFramelen) {
                                        realCpyFrameNum = purelyFramelen - encodingOffSet;
                                        pExtContent = mmfile_malloc(realCpyFrameNum + 3);