From: hj kim Date: Thu, 11 Mar 2021 07:15:19 +0000 (+0900) Subject: webrtc_source : add missing parameter check code X-Git-Tag: submit/tizen/20210729.023123~112 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F93%2F254993%2F8;p=platform%2Fcore%2Fapi%2Fwebrtc.git webrtc_source : add missing parameter check code plus, fix wrong return value [Version] 0.1.129 [Issue Type] Improvement Change-Id: I70cc965b7074047802edb0cabd36ff73f21b2f37 --- diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index 79e81cfd..a0a40707 100644 --- a/packaging/capi-media-webrtc.spec +++ b/packaging/capi-media-webrtc.spec @@ -1,6 +1,6 @@ Name: capi-media-webrtc Summary: A WebRTC library in Tizen Native API -Version: 0.1.128 +Version: 0.1.129 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc.c b/src/webrtc.c index 031fec4a..1ff9fd5c 100644 --- a/src/webrtc.c +++ b/src/webrtc.c @@ -237,6 +237,7 @@ int webrtc_get_state(webrtc_h webrtc, webrtc_state_e *state) webrtc_s *_webrtc = (webrtc_s*)webrtc; RET_VAL_IF(_webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL"); + RET_VAL_IF(state == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "state is NULL"); g_mutex_lock(&_webrtc->mutex); @@ -447,6 +448,7 @@ int webrtc_set_display(webrtc_h webrtc, unsigned int track_id, webrtc_display_ty RET_VAL_WITH_UNLOCK_IF(_webrtc->track_added_cb.callback == NULL, WEBRTC_ERROR_INVALID_OPERATION, &_webrtc->mutex, "callback was not set"); RET_VAL_WITH_UNLOCK_IF(!_is_owner_of_track_build_context(_webrtc, track_id), WEBRTC_ERROR_INVALID_OPERATION, &_webrtc->mutex, "this function should be called within the track added callback"); + RET_VAL_IF(type > WEBRTC_DISPLAY_TYPE_EVAS, WEBRTC_ERROR_INVALID_PARAMETER, "invalid display type(%d)", type); ret = _set_display_to_sink(webrtc, track_id, (unsigned int)type, (void *)display); if (ret == WEBRTC_ERROR_NONE) diff --git a/src/webrtc_display.c b/src/webrtc_display.c index b760042c..04296af1 100644 --- a/src/webrtc_display.c +++ b/src/webrtc_display.c @@ -720,7 +720,7 @@ int _apply_display(webrtc_display_s *display) default: LOG_ERROR_IF_REACHED("type(%d)", display->type); - return WEBRTC_ERROR_INVALID_OPERATION; + return WEBRTC_ERROR_INVALID_PARAMETER; } return ret; diff --git a/src/webrtc_source.c b/src/webrtc_source.c index 7fef0c0e..abe87346 100644 --- a/src/webrtc_source.c +++ b/src/webrtc_source.c @@ -1177,6 +1177,7 @@ int _add_media_source(webrtc_s *webrtc, webrtc_media_source_type_e type, unsigne RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL"); RET_VAL_IF(webrtc->gst.source_slots == NULL, WEBRTC_ERROR_INVALID_OPERATION, "source_slots is NULL"); RET_VAL_IF(source_id == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source_id is NULL"); + RET_VAL_IF(type > WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET, WEBRTC_ERROR_INVALID_PARAMETER, "invalid source type(%d)", type); /* bin_name/source will be freed by function which is set to g_hash_table_new_full() */ id = __get_unoccupied_id(webrtc->gst.source_slots);