From 23e73f7c6289dff2f1f2d1fb91ed9230e5e21b5b Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Thu, 5 Jul 2018 22:05:09 +0800 Subject: [PATCH] bug fixed --- src/Rtsp/RtspPlayer.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Rtsp/RtspPlayer.cpp b/src/Rtsp/RtspPlayer.cpp index 8f1ac3e7..4f89538c 100644 --- a/src/Rtsp/RtspPlayer.cpp +++ b/src/Rtsp/RtspPlayer.cpp @@ -228,22 +228,27 @@ bool RtspPlayer::handleAuthenticationFailure(const string ¶msStr) { return false; } - char realm[1024]; - char nonce[1024]; - char stale[1024]; + char *realm = new char[paramsStr.size()]; + char *nonce = new char[paramsStr.size()]; + char *stale = new char[paramsStr.size()]; + onceToken token(nullptr,[&](){ + delete[] realm; + delete[] nonce; + delete[] stale; + }); if (sscanf(paramsStr.data(), "Digest realm=\"%[^\"]\", nonce=\"%[^\"]\", stale=%[a-zA-Z]", realm, nonce, stale) == 3) { - (*this)[kRtspRealm] = realm; - (*this)[kRtspMd5Nonce] = nonce; + (*this)[kRtspRealm] = (const char *)realm; + (*this)[kRtspMd5Nonce] = (const char *)nonce; return true; } if (sscanf(paramsStr.data(), "Digest realm=\"%[^\"]\", nonce=\"%[^\"]\"", realm, nonce) == 2) { - (*this)[kRtspRealm] = realm; - (*this)[kRtspMd5Nonce] = nonce; + (*this)[kRtspRealm] = (const char *)realm; + (*this)[kRtspMd5Nonce] = (const char *)nonce; return true; } if (sscanf(paramsStr.data(), "Basic realm=\"%[^\"]\"", realm) == 1) { - (*this)[kRtspRealm] = realm; + (*this)[kRtspRealm] = (const char *)realm; return true; } return false;