diff options
| author | maxim_productengine <mnikolenko@productengine.com> | 2019-05-22 14:57:24 +0300 | 
|---|---|---|
| committer | maxim_productengine <mnikolenko@productengine.com> | 2019-05-22 14:57:24 +0300 | 
| commit | c289a481bdcd767e4799a3fb68808ffb68844ea1 (patch) | |
| tree | 75dab15da3c1fb103d7a5e0ae8c509d39902e78e /indra/newview | |
| parent | 8101b70999879a350a7c71b30ab820d1f2c5d0ef (diff) | |
SL-11191 FIXED Crash in LLCommandLineParser::parseCommandLineString(..)
Diffstat (limited to 'indra/newview')
| -rw-r--r-- | indra/newview/llcommandlineparser.cpp | 36 | 
1 files changed, 32 insertions, 4 deletions
| diff --git a/indra/newview/llcommandlineparser.cpp b/indra/newview/llcommandlineparser.cpp index 90a5483dc9..fe14bc081f 100644 --- a/indra/newview/llcommandlineparser.cpp +++ b/indra/newview/llcommandlineparser.cpp @@ -374,12 +374,40 @@ bool LLCommandLineParser::parseCommandLine(int argc, char **argv)  bool LLCommandLineParser::parseCommandLineString(const std::string& str)  { +    std::string cmd_line_string(""); +    if (!str.empty()) +    { +        bool add_last_c = true; +        S32 last_c_pos = str.size() - 1; //don't get out of bounds on pos+1, last char will be processed separately +        for (S32 pos = 0; pos < last_c_pos; ++pos) +        { +            cmd_line_string.append(&str[pos], 1); +            if (str[pos] == '\\') +            { +                cmd_line_string.append("\\", 1); +                if (str[pos + 1] == '\\') +                { +                    ++pos; +                    add_last_c = (pos != last_c_pos); +                } +            } +        } +        if (add_last_c) +        { +            cmd_line_string.append(&str[last_c_pos], 1); +            if (str[last_c_pos] == '\\') +            { +                cmd_line_string.append("\\", 1); +            } +        } +    } +      // Split the string content into tokens -	const char* escape_chars = "\\"; -	const char* separator_chars = "\r\n "; -	const char* quote_chars = "\"'"; +    const char* escape_chars = "\\"; +    const char* separator_chars = "\r\n "; +    const char* quote_chars = "\"'";      boost::escaped_list_separator<char> sep(escape_chars, separator_chars, quote_chars); -    boost::tokenizer< boost::escaped_list_separator<char> > tok(str, sep); +    boost::tokenizer< boost::escaped_list_separator<char> > tok(cmd_line_string, sep);      std::vector<std::string> tokens;      // std::copy(tok.begin(), tok.end(), std::back_inserter(tokens));      for(boost::tokenizer< boost::escaped_list_separator<char> >::iterator i = tok.begin(); | 
