Skip to content

Commit 80a6a38

Browse files
committed
Fix Bug: Memory leak when creating the AGMDB handler
1 parent 8631ff1 commit 80a6a38

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

apache2/persist_dbm.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -604,9 +604,9 @@ static int collection_store_ex(int db_option, modsec_rec *msr, apr_table_t *col)
604604
msr_log_error(msr, "[ERROR]collection_retrieve_ex_agmdb: Cannot find root_config in msr->dcfg1.");
605605
goto error;
606606
}
607-
new_handle = (struct agmdb_handle_entry *)malloc(sizeof(struct agmdb_handle_entry));
608-
new_handle->col_name = (char*)malloc(var_name->value_len);
609-
new_handle->handle = malloc(sizeof(struct agmdb_handler));
607+
new_handle = (struct agmdb_handle_entry *)apr_pcalloc(root_dcfg->mp, sizeof(struct agmdb_handle_entry));
608+
new_handle->col_name = (char*)apr_pcalloc(root_dcfg->mp, var_name->value_len);
609+
new_handle->handle = apr_pcalloc(root_dcfg->mp, sizeof(struct agmdb_handler));
610610
strcpy((char*)(new_handle->col_name), var_name->value);
611611

612612
rc = AGMDB_openDB(new_handle->handle, new_db_name, strlen(new_db_name), DEFAULT_AGMDB_ENTRY_NUM);

0 commit comments

Comments
 (0)