fix svace issue 11/75511/1
authorEunhae Choi <eunhae1.choi@samsung.com>
Mon, 20 Jun 2016 07:47:47 +0000 (16:47 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Mon, 20 Jun 2016 07:47:47 +0000 (16:47 +0900)
Change-Id: I837f6070aff96726f6862bcd2c71e60b7351a69f

src/media_streamer_gst.c
src/media_streamer_node.c

index 89ba38df36e67b8acddcecd08f42fbdc38798b65..76e53496c6ff4b593c5fbdd003a07867a6d3ae13 100755 (executable)
@@ -691,9 +691,11 @@ static void __ms_rtpbin_pad_added_cb(GstElement * src, GstPad * new_pad, gpointe
                if (source_pad_name != NULL) {
 
                        GstPad *source_pad = gst_element_get_static_pad(ms_node->gst_element, source_pad_name);
-                       gst_ghost_pad_set_target(GST_GHOST_PAD(source_pad), new_pad);
 
-                       if (__ms_sink_bin_prepare(ms_streamer, source_pad, src_pad_type)) {
+                       if (source_pad)
+                               gst_ghost_pad_set_target(GST_GHOST_PAD(source_pad), new_pad);
+
+                       if (source_pad && __ms_sink_bin_prepare(ms_streamer, source_pad, src_pad_type)) {
                                __ms_element_set_state(ms_node->gst_element, GST_STATE_PLAYING);
                                __ms_generate_dots(ms_streamer->pipeline, "rtpbin_playing");
                        } else {
@@ -1274,6 +1276,12 @@ static GstPadProbeReturn __ms_element_event_probe(GstPad * pad, GstPadProbeInfo
 {
        GstElement *parent_element = gst_pad_get_parent_element(pad);
        GstEvent *event = GST_PAD_PROBE_INFO_EVENT(info);
+
+       if (!parent_element) {
+               ms_error("filed to get parent_elem");
+               return GST_PAD_PROBE_PASS;
+       }
+
        if (GST_PAD_PROBE_INFO_TYPE(info) & GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM) {
                if (GST_EVENT_TYPE(event) == GST_EVENT_BUFFERSIZE) {
                        GValue *val_ = (GValue *) g_object_get_data(G_OBJECT(parent_element), "pad_sink");
@@ -1292,6 +1300,10 @@ void __ms_element_lock_state(const GValue *item, gpointer user_data)
        ms_retm_if(!sink_element, "Handle is NULL");
 
        GstPad *sink_pad = gst_element_get_static_pad(sink_element, "sink");
+       if (!sink_pad) {
+               ms_info("Failed to get static pad of element [%s]", GST_ELEMENT_NAME(sink_element));
+               return;
+       }
        if (!gst_pad_is_blocked(sink_pad)) {
                int probe_id = gst_pad_add_probe(sink_pad, GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM, __ms_element_event_probe, NULL, NULL);
                MS_SET_INT_PARAM(sink_element, "pad_sink", probe_id);
@@ -1310,6 +1322,10 @@ void __ms_element_unlock_state(const GValue *item, gpointer user_data)
        GValue *val = (GValue *) g_object_get_data(G_OBJECT(sink_element), "pad_sink");
        if (val) {
                GstPad *sink_pad = gst_element_get_static_pad(sink_element, "sink");
+               if (!sink_pad) {
+                       ms_info("Failed to get static pad of element [%s]", GST_ELEMENT_NAME(sink_element));
+                       return;
+               }
                if (gst_pad_is_blocked(sink_pad)) {
                        ms_info("Removing locking probe [%d] ID on [%s] pad of [%s] element", g_value_get_int(val), GST_PAD_NAME(sink_pad), GST_ELEMENT_NAME(sink_element));
                        gst_pad_remove_probe(sink_pad, g_value_get_int(val));
@@ -1673,9 +1689,9 @@ int __ms_element_set_fmt(media_streamer_node_s *node, const char *pad_name, medi
        GstElementFactory *factory = gst_element_get_factory(node->gst_element);
        GstPad *node_pad = gst_element_get_static_pad(node->gst_element, pad_name);
 
-       if (GST_PAD_IS_SRC(node_pad))
+       if (node_pad && GST_PAD_IS_SRC(node_pad))
                can_accept  = gst_element_factory_can_src_any_caps(factory, fmt_caps);
-       else if (GST_PAD_IS_SINK(node_pad))
+       else if (node_pad && GST_PAD_IS_SINK(node_pad))
                can_accept  = gst_element_factory_can_sink_any_caps(factory, fmt_caps);
        else
                ms_error(" Node [%s] doesn`t have valid pad [%s]", node->name, pad_name);
index 6443f0dc358aa6da3210e2d6e1f15d98eec4f09d..50c45ff425f47d2c8635f66973626ed4a8ce7c39 100755 (executable)
@@ -802,7 +802,7 @@ int __ms_node_get_param_list(media_streamer_node_s *node, GList **param_list)
 int __ms_node_get_param_value(media_streamer_node_s *node, param_s *param, char **string_value)
 {
        char *string_val = NULL;
-       GParamSpec *param_spec;
+       GParamSpec *param_spec = NULL;
        GValue value = G_VALUE_INIT;
 
        int ret = MEDIA_STREAMER_ERROR_NONE;
@@ -811,11 +811,15 @@ int __ms_node_get_param_value(media_streamer_node_s *node, param_s *param, char
                ret = __ms_rtp_node_get_property(node, param, &value);
        else {
                param_spec = g_object_class_find_property(G_OBJECT_GET_CLASS(node->gst_element), param->origin_name);
+               if (param_spec) {
+                       g_value_init(&value, param_spec->value_type);
+                       g_object_get_property(G_OBJECT(node->gst_element), param->origin_name, &value);
 
-               g_value_init(&value, param_spec->value_type);
-               g_object_get_property(G_OBJECT(node->gst_element), param->origin_name, &value);
-
-               ms_info("Got parameter [%s] for node [%s] with description [%s]", param->param_name, node->name, g_param_spec_get_blurb(param_spec));
+                       ms_info("Got parameter [%s] for node [%s] with description [%s]", param->param_name, node->name, g_param_spec_get_blurb(param_spec));
+               } else {
+                       ms_error("There is no parameter [%s] for node [%s]", param->origin_name, node->name);
+                       return MEDIA_STREAMER_ERROR_INVALID_PARAMETER;
+               }
        }
 
        if (!g_strcmp0(param->param_name, MEDIA_STREAMER_PARAM_CAMERA_ID))
@@ -894,6 +898,8 @@ int __ms_node_uri_path_check(const char *file_uri)
 
                if (EACCES == errno)
                        return MEDIA_STREAMER_ERROR_PERMISSION_DENIED;
+
+               return MEDIA_STREAMER_ERROR_INVALID_PARAMETER;
        }
 
        if (fstat(file_open, &stat_results) < 0) {