mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-11-18 10:20:35 +03:00
Extends the direct access model to other collections
This commit is contained in:
committed by
Felipe Zimmerle
parent
ca24b6bb06
commit
f2d149fc5f
@@ -155,11 +155,11 @@ void InMemoryPerProcess::resolveRegularExpression(const std::string& var,
|
||||
}
|
||||
|
||||
|
||||
std::string* InMemoryPerProcess::resolveFirst(const std::string& var) {
|
||||
std::unique_ptr<std::string> InMemoryPerProcess::resolveFirst(const std::string& var) {
|
||||
auto range = equal_range(var);
|
||||
|
||||
for (auto it = range.first; it != range.second; ++it) {
|
||||
return &it->second;
|
||||
return std::unique_ptr<std::string>(new std::string(it->second));
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
@@ -82,7 +82,7 @@ class InMemoryPerProcess :
|
||||
|
||||
void del(const std::string& key) override;
|
||||
|
||||
std::string* resolveFirst(const std::string& var) override;
|
||||
std::unique_ptr<std::string> resolveFirst(const std::string& var) override;
|
||||
|
||||
void resolveSingleMatch(const std::string& var,
|
||||
std::vector<const Variable *> *l) override;
|
||||
|
||||
@@ -161,7 +161,7 @@ void LMDB::lmdb_debug(int rc, std::string op, std::string scope) {
|
||||
}
|
||||
|
||||
|
||||
std::string* LMDB::resolveFirst(const std::string& var) {
|
||||
std::unique_ptr<std::string> LMDB::resolveFirst(const std::string& var) {
|
||||
int rc;
|
||||
MDB_val mdb_key;
|
||||
MDB_val mdb_value;
|
||||
@@ -188,10 +188,9 @@ std::string* LMDB::resolveFirst(const std::string& var) {
|
||||
goto end_get;
|
||||
}
|
||||
|
||||
// FIXME: Memory leak here.
|
||||
ret = new std::string(
|
||||
ret = std::unique_ptr<std::string>(new std::string(
|
||||
reinterpret_cast<char *>(mdb_value_ret.mv_data),
|
||||
mdb_value_ret.mv_size);
|
||||
mdb_value_ret.mv_size));
|
||||
|
||||
end_get:
|
||||
mdb_dbi_close(m_env, dbi);
|
||||
|
||||
@@ -61,7 +61,7 @@ class LMDB :
|
||||
|
||||
void del(const std::string& key) override;
|
||||
|
||||
std::string* resolveFirst(const std::string& var) override;
|
||||
std::unique_ptr<std::string> resolveFirst(const std::string& var) override;
|
||||
|
||||
void resolveSingleMatch(const std::string& var,
|
||||
std::vector<const Variable *> *l) override;
|
||||
|
||||
Reference in New Issue
Block a user