mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Code cleanup: Initialize variables and others good practice
- initialize invalid_countin UrlDecode :: evaluate - Free resources before the process die (good practice)
This commit is contained in:
committed by
Felipe Zimmerle
parent
a278bb673a
commit
e4c822e663
@@ -40,7 +40,7 @@ UrlDecode::UrlDecode(std::string action)
|
||||
std::string UrlDecode::evaluate(std::string value,
|
||||
Transaction *transaction) {
|
||||
unsigned char *val = NULL;
|
||||
int invalid_count;
|
||||
int invalid_count = 0;
|
||||
int changed;
|
||||
|
||||
val = (unsigned char *) malloc(sizeof(char) * value.size() + 1);
|
||||
|
@@ -461,8 +461,11 @@ TreeNode *CPTAddElement(unsigned char *ipdata, unsigned int ip_bitmask, CPTTree
|
||||
} else {
|
||||
i_node = CPTCreateNode();
|
||||
|
||||
if(i_node == NULL)
|
||||
if (i_node == NULL) {
|
||||
free(new_node->prefix);
|
||||
free(new_node);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//i_node->prefix = NULL;
|
||||
i_node->bit = test_bit;
|
||||
@@ -480,6 +483,9 @@ TreeNode *CPTAddElement(unsigned char *ipdata, unsigned int ip_bitmask, CPTTree
|
||||
i_node->netmasks = reinterpret_cast<unsigned char *>(malloc((node->count - i) * sizeof(unsigned char)));
|
||||
|
||||
if(i_node->netmasks == NULL) {
|
||||
free(new_node->prefix);
|
||||
free(new_node);
|
||||
free(i_node);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user