Merge pull request #506 from phord/master

string2level uses wrong string length
This commit is contained in:
Tim Stack 2018-03-27 10:11:22 -07:00 committed by GitHub
commit 09e7e14167
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -108,7 +108,8 @@ logline::level_t logline::string2level(const char *levelstr, ssize_t len, bool e
pcre_context_static<10> pc; pcre_context_static<10> pc;
if (LEVEL_RE.match(pc, pi)) { if (LEVEL_RE.match(pc, pi)) {
retval = abbrev2level(pi.get_substr_start(pc.begin()), len); auto iter = pc.begin();
retval = abbrev2level(pi.get_substr_start(iter), pi.get_substr_len(iter));
} }
return retval; return retval;

View File

@ -227,6 +227,11 @@ public:
return &this->pi_string[iter->c_begin]; return &this->pi_string[iter->c_begin];
}; };
size_t get_substr_len(pcre_context::const_iterator iter) const
{
return iter->length();
};
std::string get_substr(pcre_context::const_iterator iter) const std::string get_substr(pcre_context::const_iterator iter) const
{ {
if (iter->c_begin == -1) { if (iter->c_begin == -1) {