diff options
author | Gilbok Lee <gilbok.lee@samsung.com> | 2016-12-12 18:58:55 +0900 |
---|---|---|
committer | Gilbok Lee <gilbok.lee@samsung.com> | 2016-12-12 18:58:55 +0900 |
commit | c2b1a585ca9874de5bdd977e4d47599ca1c64e12 (patch) | |
tree | 7cb705b0b010a9aece33058df78993f0396bea7c | |
parent | e13b53074d5ab1ae0280090689168218378deef1 (diff) | |
download | video-util-c2b1a585ca9874de5bdd977e4d47599ca1c64e12.tar.gz video-util-c2b1a585ca9874de5bdd977e4d47599ca1c64e12.tar.bz2 video-util-c2b1a585ca9874de5bdd977e4d47599ca1c64e12.zip |
Fix crash during destroy(due to double free)submit/tizen_3.0/20161215.110001submit/tizen_3.0/20161213.081002accepted/tizen/3.0/tv/20161216.084008accepted/tizen/3.0/mobile/20161216.083713accepted/tizen/3.0/ivi/20161216.084239accepted/tizen/3.0/common/20161216.123518
[Version] 0.1.8
[Profile] Common, Mobile, TV)
[Issue Type] Fix bugs
Change-Id: I8365b6033b3fdd5e4e01bf157c4e0f6b248b91c4
-rwxr-xr-x | packaging/capi-media-video-util.spec | 4 | ||||
-rwxr-xr-x | src/video_util.c | 18 | ||||
-rw-r--r-- | test/video_util_test.c | 34 |
3 files changed, 40 insertions, 16 deletions
diff --git a/packaging/capi-media-video-util.spec b/packaging/capi-media-video-util.spec index 040565d..c895775 100755 --- a/packaging/capi-media-video-util.spec +++ b/packaging/capi-media-video-util.spec @@ -1,7 +1,7 @@ Name: capi-media-video-util Summary: A Video Utility library in Tizen Native API -Version: 0.1.7 -Release: 6 +Version: 0.1.8 +Release: 0 Group: System/Libraries License: Apache-2.0 Source0: %{name}-%{version}.tar.gz diff --git a/src/video_util.c b/src/video_util.c index 2d7b30e..f433983 100755 --- a/src/video_util.c +++ b/src/video_util.c @@ -223,10 +223,11 @@ static video_util_error_e __video_util_error_convert(int error) static void __video_util_transcode_progress_cb(unsigned long current_position, unsigned long duration, void *user_data) { - video_util_cb_s *_util_cb = (video_util_cb_s *)user_data; + video_util_s *_handle = (video_util_s *)user_data; - if ((_util_cb != NULL) && (_util_cb->transcode_progress_cb != NULL)) - _util_cb->transcode_progress_cb(current_position, duration, _util_cb->user_data); + if ((_handle != NULL) && (_handle->_util_cb != NULL) + && (_handle->_util_cb->transcode_progress_cb != NULL)) + _handle->_util_cb->transcode_progress_cb(current_position, duration, _handle->_util_cb->user_data); return; } @@ -234,14 +235,15 @@ static void __video_util_transcode_progress_cb(unsigned long current_position, u static void __video_util_transcode_completed_cb(int error, void *user_data) { int error_value = VIDEO_UTIL_ERROR_NONE; - video_util_cb_s *_util_cb = (video_util_cb_s *)user_data; + video_util_s *_handle = (video_util_s *)user_data; - if ((_util_cb != NULL) && (_util_cb->transcode_completed_cb != NULL)) { + if ((_handle != NULL) && (_handle->_util_cb != NULL) + && (_handle->_util_cb->transcode_completed_cb != NULL)) { error_value = __video_util_error_convert(error); - _util_cb->transcode_completed_cb(error_value, _util_cb->user_data); + _handle->_util_cb->transcode_completed_cb(error_value, _handle->_util_cb->user_data); } - UTIL_SAFE_FREE(_util_cb); + UTIL_SAFE_FREE(_handle->_util_cb); return; } @@ -661,7 +663,7 @@ int video_util_start_transcoding(video_util_h handle, unsigned long start, unsig else accurate_mode = MM_SEEK_INACCURATE; - ret = mm_transcode(_handle->transcode_h, _handle->width, _handle->height, _handle->fps, start, duration, accurate_mode, out_path, (mm_transcode_progress_callback)__video_util_transcode_progress_cb, (mm_transcode_completed_callback)__video_util_transcode_completed_cb, (void *)_handle->_util_cb); + ret = mm_transcode(_handle->transcode_h, _handle->width, _handle->height, _handle->fps, start, duration, accurate_mode, out_path, (mm_transcode_progress_callback)__video_util_transcode_progress_cb, (mm_transcode_completed_callback)__video_util_transcode_completed_cb, (void *)_handle); if (ret != MM_ERROR_NONE) { UTIL_SAFE_FREE(_handle->_util_cb); diff --git a/test/video_util_test.c b/test/video_util_test.c index ab6a877..fe170bb 100644 --- a/test/video_util_test.c +++ b/test/video_util_test.c @@ -68,6 +68,9 @@ typedef struct { unsigned long duration; } test_util_s; +test_util_s *_util_s; + + static void display_sub_basic(); void _video_util_start_transcoding(test_util_s *util_s); @@ -144,14 +147,16 @@ void _transcode_completed_cb(video_util_error_e error, void *user_data) test_util_s *_util_s = (test_util_s *)user_data; + if (!_util_s) { + LOGE("completed_cb user data is NULL"); + return; + } + LOGI("transcode_completed_cb============= [%2d / %2d][%d]\n", _util_s->idx, make_video_cnt, error); printf("transcode_completed_cb============= [%2d / %2d][%d]\n", _util_s->idx, make_video_cnt, error); if (_util_s->idx == (make_video_cnt - 1)) { LOGI("End trascoding"); - video_util_destroy(_util_s->video_h); - _util_s->video_h = NULL; - video_h = NULL; return; } @@ -314,10 +319,13 @@ void _interpret_main_menu(char *cmd) if (strncmp(cmd, "a", 1) == 0) { g_menu_state = CURRENT_STATUS_FILENAME; } else if (strncmp(cmd, "s", 1) == 0) { + if (!_util_s) { + _util_s = (test_util_s *)calloc(1, sizeof(test_util_s)); + LOGE("_util_s malloc"); + } - test_util_s *_util_s = (test_util_s *)calloc(1, sizeof(test_util_s)); if (!_util_s) { - g_print("test util calloc failed"); + LOGE("test util calloc failed"); return; } @@ -349,6 +357,19 @@ void _interpret_main_menu(char *cmd) g_menu_state = CURRENT_STATUS_SET_OUTFILENAME; } else if (strncmp(cmd, "q", 1) == 0) { _quit_program(); + } else if (strncmp(cmd, "d", 1) == 0) { + int ret = VIDEO_UTIL_ERROR_NONE; + if (!video_h) { + g_print("video_util handle is NULL, please set format after create"); + return;; + } + ret = video_util_destroy(video_h); + if (ret != VIDEO_UTIL_ERROR_NONE) { + g_print("video_util_cancel_transcoding is failed (%d)", ret); + return; + } + free(_util_s); + _util_s = NULL; } else { g_print("unknown menu \n"); } @@ -627,7 +648,8 @@ static void display_sub_basic() g_print("vf. Set video fps\n"); g_print(" t. Set start/duration time \t"); g_print(" o. Set output filename\t"); - g_print(" q. quite test suite\t"); + g_print(" q. quite test suite\t\n"); + g_print(" d. Destroy\t"); g_print("\n"); g_print("=========================================================================================\n"); } |