Fix dereferencing null pointer problem 18/54518/2 accepted/tizen/mobile/20151216.110822 accepted/tizen/tv/20151216.110512 accepted/tizen/wearable/20151216.110527 submit/tizen/20151216.054237
authorHyunjun Ko <zzoon.ko@samsung.com>
Wed, 16 Dec 2015 01:09:11 +0000 (10:09 +0900)
committerHyunjun Ko <zzoon.ko@samsung.com>
Wed, 16 Dec 2015 04:11:44 +0000 (13:11 +0900)
Change-Id: I2524622ca707ed8b554e6feef3171b29e90732c1

gst/rtsp-server/gstwfdmessage.c

index b70e57d..3dbd6db 100755 (executable)
@@ -1808,7 +1808,7 @@ gst_wfd_message_get_contentprotection_type (GstWFDMessage * msg,
   g_return_val_if_fail (msg != NULL, GST_WFD_EINVAL);
   if (msg->content_protection && msg->content_protection->hdcp2_spec) {
     char *result = NULL;
-    char *ptr = NULL;
+    char *ptr[2] = {0, };
     if (!g_strcmp0 (msg->content_protection->hdcp2_spec->hdcpversion, "none")) {
       *hdcpversion = GST_WFD_HDCP_NONE;
       *TCPPort = 0;
@@ -1826,11 +1826,15 @@ gst_wfd_message_get_contentprotection_type (GstWFDMessage * msg,
       return GST_WFD_OK;
     }
 
-    result = strtok_r (msg->content_protection->hdcp2_spec->TCPPort, "=", &ptr);
-    while (result != NULL) {
-      result = strtok_r (NULL, "=", &ptr);
-      *TCPPort = atoi (result);
-      break;
+    if (msg->content_protection->hdcp2_spec->TCPPort) {
+      result = strtok_r (msg->content_protection->hdcp2_spec->TCPPort, "=", &ptr[0]);
+      while (result != NULL) {
+        result = strtok_r (NULL, "=", &ptr[1]);
+        *TCPPort = atoi (result);
+        break;
+      }
+    } else {
+      *TCPPort = 0;
     }
   } else
     *hdcpversion = GST_WFD_HDCP_NONE;