mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Handles better the memory utilization
- Added reference counts to Rule and AuditLog; - Some memory leaks were removed, including GeoLookup; - Deal better with parser errors; - Overriding the AutlogLogWritter destructor.
This commit is contained in:
@@ -30,8 +30,20 @@ namespace ModSecurity {
|
||||
namespace Utils {
|
||||
|
||||
|
||||
bool GeoLookup::setDataBase(std::string file_path) {
|
||||
m_gi = GeoIP_open(file_path.c_str(), GEOIP_INDEX_CACHE);
|
||||
GeoLookup::~GeoLookup() {
|
||||
cleanUp();
|
||||
}
|
||||
|
||||
void GeoLookup::cleanUp() {
|
||||
if (m_gi != NULL) {
|
||||
GeoIP_delete(m_gi);
|
||||
m_gi = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool GeoLookup::setDataBase(const std::string& filePath) {
|
||||
m_gi = GeoIP_open(filePath.c_str(), GEOIP_INDEX_CACHE);
|
||||
|
||||
if (m_gi == NULL) {
|
||||
return false;
|
||||
|
@@ -36,13 +36,15 @@ class GeoLookup {
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool setDataBase(std::string file_path);
|
||||
bool setDataBase(const std::string& filePath);
|
||||
bool lookup(const std::string& target, GeoIPRecord **georec,
|
||||
std::function<bool(int, std::string)> callback);
|
||||
void cleanUp();
|
||||
|
||||
private:
|
||||
GeoLookup() : m_gi(NULL) {}
|
||||
|
||||
GeoLookup()
|
||||
: m_gi(NULL) { }
|
||||
~GeoLookup();
|
||||
GeoLookup(GeoLookup const&);
|
||||
void operator=(GeoLookup const&);
|
||||
|
||||
|
Reference in New Issue
Block a user