Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c60709a

Browse files
committed
fix: rx operators better null checks
1 parent 08b70e0 commit c60709a

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

‎src/operators/rx.cc‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,20 @@ bool Rx::evaluate(Transaction *transaction, RuleWithActions *rule,
6868

6969
// FIXME: DRY regex error reporting. This logic is currently duplicated in other operators.
7070
if (regex_result != Utils::RegexResult::Ok) {
71-
transaction->m_variableMscPcreError.set("1", transaction->m_variableOffset);
72-
73-
std::string regex_error_str = "OTHER";
74-
if (regex_result == Utils::RegexResult::ErrorMatchLimit) {
75-
regex_error_str = "MATCH_LIMIT";
76-
transaction->m_variableMscPcreLimitsExceeded.set("1", transaction->m_variableOffset);
77-
transaction->m_collections.m_tx_collection->storeOrUpdateFirst("MSC_PCRE_LIMITS_EXCEEDED", "1");
78-
ms_dbg_a(transaction, 7, "Set TX.MSC_PCRE_LIMITS_EXCEEDED to 1");
71+
if (transaction) {
72+
transaction->m_variableMscPcreError.set("1", transaction->m_variableOffset);
73+
74+
std::string regex_error_str = "OTHER";
75+
if (regex_result == Utils::RegexResult::ErrorMatchLimit) {
76+
regex_error_str = "MATCH_LIMIT";
77+
transaction->m_variableMscPcreLimitsExceeded.set("1", transaction->m_variableOffset);
78+
transaction->m_collections.m_tx_collection->storeOrUpdateFirst("MSC_PCRE_LIMITS_EXCEEDED", "1");
79+
ms_dbg_a(transaction, 7, "Set TX.MSC_PCRE_LIMITS_EXCEEDED to 1");
80+
}
81+
82+
ms_dbg_a(transaction, 1, "rx: regex error '" + regex_error_str + "' for pattern '" + re->pattern + "'");
7983
}
8084

81-
ms_dbg_a(transaction, 1, "rx: regex error '" + regex_error_str + "' for pattern '" + re->pattern + "'");
82-
83-
8485
return false;
8586
}
8687

‎src/operators/rx_global.cc‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,20 @@ bool RxGlobal::evaluate(Transaction *transaction, RuleWithActions *rule,
6262

6363
// FIXME: DRY regex error reporting. This logic is currently duplicated in other operators.
6464
if (regex_result != Utils::RegexResult::Ok) {
65-
transaction->m_variableMscPcreError.set("1", transaction->m_variableOffset);
66-
67-
std::string regex_error_str = "OTHER";
68-
if (regex_result == Utils::RegexResult::ErrorMatchLimit) {
69-
regex_error_str = "MATCH_LIMIT";
70-
transaction->m_variableMscPcreLimitsExceeded.set("1", transaction->m_variableOffset);
71-
transaction->m_collections.m_tx_collection->storeOrUpdateFirst("MSC_PCRE_LIMITS_EXCEEDED", "1");
72-
ms_dbg_a(transaction, 7, "Set TX.MSC_PCRE_LIMITS_EXCEEDED to 1");
65+
if (transaction) {
66+
transaction->m_variableMscPcreError.set("1", transaction->m_variableOffset);
67+
68+
std::string regex_error_str = "OTHER";
69+
if (regex_result == Utils::RegexResult::ErrorMatchLimit) {
70+
regex_error_str = "MATCH_LIMIT";
71+
transaction->m_variableMscPcreLimitsExceeded.set("1", transaction->m_variableOffset);
72+
transaction->m_collections.m_tx_collection->storeOrUpdateFirst("MSC_PCRE_LIMITS_EXCEEDED", "1");
73+
ms_dbg_a(transaction, 7, "Set TX.MSC_PCRE_LIMITS_EXCEEDED to 1");
74+
}
75+
76+
ms_dbg_a(transaction, 1, "rxGlobal: regex error '" + regex_error_str + "' for pattern '" + re->pattern + "'");
7377
}
7478

75-
ms_dbg_a(transaction, 1, "rxGlobal: regex error '" + regex_error_str + "' for pattern '" + re->pattern + "'");
76-
7779
return false;
7880
}
7981

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /