From 8d671acd29a3420e775d9a255f6142c4b1337d64 Mon Sep 17 00:00:00 2001 From: Hyunjun Ko Date: Wed, 16 Dec 2015 10:09:11 +0900 Subject: [PATCH] Fix dereferencing null pointer problem Change-Id: I2524622ca707ed8b554e6feef3171b29e90732c1 --- gst/rtsp-server/gstwfdmessage.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/gst/rtsp-server/gstwfdmessage.c b/gst/rtsp-server/gstwfdmessage.c index b70e57d..3dbd6db 100755 --- a/gst/rtsp-server/gstwfdmessage.c +++ b/gst/rtsp-server/gstwfdmessage.c @@ -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; -- 2.7.4