diff --git a/daemon/src/sip/sdes_negotiator.cpp b/daemon/src/sip/sdes_negotiator.cpp index 1d0d808e13dda73498234d8de8e3ae975ac543af..63bb00b8231cfd851da960d22c409b1ac7d3500c 100644 --- a/daemon/src/sip/sdes_negotiator.cpp +++ b/daemon/src/sip/sdes_negotiator.cpp @@ -32,6 +32,7 @@ #include "pattern.h" #include <cstdio> +#include <memory> #include <iostream> #include <sstream> #include <algorithm> @@ -60,30 +61,27 @@ std::vector<CryptoAttribute *> SdesNegotiator::parse() // syntax : //a=crypto:tag 1*WSP crypto-suite 1*WSP key-params *(1*WSP session-param) - Pattern - * generalSyntaxPattern, - * tagPattern, - * cryptoSuitePattern, - * keyParamsPattern; + std::auto_ptr<Pattern> generalSyntaxPattern, tagPattern, cryptoSuitePattern, + keyParamsPattern; try { // used to match white space (which are used as separator) - generalSyntaxPattern = new Pattern("[\x20\x09]+", "g"); + generalSyntaxPattern.reset(new Pattern("[\x20\x09]+", "g")); - tagPattern = new Pattern("^a=crypto:(?P<tag>[0-9]{1,9})"); + tagPattern.reset(new Pattern("^a=crypto:(?P<tag>[0-9]{1,9})")); - cryptoSuitePattern = new Pattern( + cryptoSuitePattern.reset(new Pattern( "(?P<cryptoSuite>AES_CM_128_HMAC_SHA1_80|" \ "AES_CM_128_HMAC_SHA1_32|" \ "F8_128_HMAC_SHA1_80|" \ - "[A-Za-z0-9_]+)"); // srtp-crypto-suite-ext + "[A-Za-z0-9_]+)")); // srtp-crypto-suite-ext - keyParamsPattern = new Pattern( + keyParamsPattern.reset(new Pattern( "(?P<srtpKeyMethod>inline|[A-Za-z0-9_]+)\\:" \ "(?P<srtpKeyInfo>[A-Za-z0-9\x2B\x2F\x3D]+)" \ "(\\|2\\^(?P<lifetime>[0-9]+)\\|" \ "(?P<mkiValue>[0-9]+)\\:" \ - "(?P<mkiLength>[0-9]{1,3})\\;?)?", "g"); + "(?P<mkiLength>[0-9]{1,3})\\;?)?", "g")); } catch (const CompileError& exception) { throw ParseError("A compile exception occured on a pattern.");