Correctly handle return values from pcre_study(3)

If both function's return value and errptr are NULLs, it means
that pcre_study() does not make sense, so can be ignored.
This commit is contained in:
Alexey Zelkin 2016-07-05 09:32:29 +00:00 committed by Felipe Zimmerle
parent e231503bc9
commit afd7a21d11
No known key found for this signature in database
GPG Key ID: E6DFB08CE8B11277

View File

@ -85,9 +85,20 @@ bool VerifyCC::init(const std::string &param2, std::string *error) {
m_pc = pcre_compile(param.c_str(), PCRE_DOTALL|PCRE_MULTILINE,
&errptr, &erroffset, NULL);
m_pce = pcre_study(m_pc, PCRE_STUDY_JIT_COMPILE, &errptr);
if (m_pc == NULL) {
error->assign(errptr);
return false;
}
if ((m_pc == NULL) || (m_pce == NULL)) {
m_pce = pcre_study(m_pc, PCRE_STUDY_JIT_COMPILE, &errptr);
if (m_pce == NULL) {
if (errptr == NULL) {
/*
* Per pcre_study(3) m_pce == NULL && errptr == NULL means
* that no addional information is found, so no need to study
*/
return true;
}
error->assign(errptr);
return false;
}