mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Fixed memory leak in examples/reading_logs_via_rule_message
This commit is contained in:
parent
4288f5a009
commit
b872f11f68
@ -130,29 +130,25 @@ class ReadingLogsViaRuleMessage {
|
|||||||
struct data_ms dms;
|
struct data_ms dms;
|
||||||
void *status;
|
void *status;
|
||||||
|
|
||||||
modsecurity::ModSecurity *modsec;
|
auto modsec = std::make_unique<modsecurity::ModSecurity>();
|
||||||
modsecurity::RulesSet *rules;
|
|
||||||
|
|
||||||
modsec = new modsecurity::ModSecurity();
|
|
||||||
modsec->setConnectorInformation("ModSecurity-test v0.0.1-alpha" \
|
modsec->setConnectorInformation("ModSecurity-test v0.0.1-alpha" \
|
||||||
" (ModSecurity test)");
|
" (ModSecurity test)");
|
||||||
modsec->setServerLogCb(logCb, modsecurity::RuleMessageLogProperty
|
modsec->setServerLogCb(logCb, modsecurity::RuleMessageLogProperty
|
||||||
| modsecurity::IncludeFullHighlightLogProperty);
|
| modsecurity::IncludeFullHighlightLogProperty);
|
||||||
|
|
||||||
rules = new modsecurity::RulesSet();
|
auto rules = std::make_unique<modsecurity::RulesSet>();
|
||||||
if (rules->loadFromUri(m_rules.c_str()) < 0) {
|
if (rules->loadFromUri(m_rules.c_str()) < 0) {
|
||||||
std::cout << "Problems loading the rules..." << std::endl;
|
std::cout << "Problems loading the rules..." << std::endl;
|
||||||
std::cout << rules->m_parserError.str() << std::endl;
|
std::cout << rules->m_parserError.str() << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
dms.modsec = modsec;
|
dms.modsec = modsec.get();
|
||||||
dms.rules = rules;
|
dms.rules = rules.get();
|
||||||
|
|
||||||
for (i = 0; i < NUM_THREADS; i++) {
|
for (i = 0; i < NUM_THREADS; i++) {
|
||||||
pthread_create(&threads[i], NULL, process_request,
|
pthread_create(&threads[i], NULL, process_request,
|
||||||
reinterpret_cast<void *>(&dms));
|
reinterpret_cast<void *>(&dms));
|
||||||
// process_request((void *)&dms);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(10000);
|
usleep(10000);
|
||||||
@ -162,8 +158,6 @@ class ReadingLogsViaRuleMessage {
|
|||||||
std::cout << "Main: completed thread id :" << i << std::endl;
|
std::cout << "Main: completed thread id :" << i << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete rules;
|
|
||||||
delete modsec;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,5 +101,4 @@ stlcstrStream
|
|||||||
uselessCallsSubstr
|
uselessCallsSubstr
|
||||||
|
|
||||||
// Examples
|
// Examples
|
||||||
memleak:examples/reading_logs_via_rule_message/reading_logs_via_rule_message.h:147
|
|
||||||
memleak:examples/using_bodies_in_chunks/simple_request.cc
|
memleak:examples/using_bodies_in_chunks/simple_request.cc
|
||||||
|
Loading…
x
Reference in New Issue
Block a user