Module: sip-router
Branch: master
Commit: 52ce2349234da4b82bff28eed1bb89baad645a96
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=52ce234…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Thu Jan 13 11:20:07 2011 +0100
snmpstats: fixed faulty allocation of snmp stats array
- the size of struct was used while the pointer to that struct was in
the array
- reported by Paul Pankhurst
---
modules_k/snmpstats/snmpstats.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/modules_k/snmpstats/snmpstats.c b/modules_k/snmpstats/snmpstats.c
index 89ac61b..9e52c03 100644
--- a/modules_k/snmpstats/snmpstats.c
+++ b/modules_k/snmpstats/snmpstats.c
@@ -195,10 +195,10 @@ static int register_message_code_statistics(void)
sizeof(in_message_code_names) / sizeof(char *);
in_message_code_stats =
- shm_malloc(sizeof(stat_var) * number_of_message_codes);
+ shm_malloc(sizeof(stat_var*) * number_of_message_codes);
out_message_code_stats =
- shm_malloc(sizeof(stat_var) * number_of_message_codes);
+ shm_malloc(sizeof(stat_var*) * number_of_message_codes);
/* We can only proceed if we had enough memory to allocate the
* statistics. Note that we don't free the memory, but we don't care
@@ -210,8 +210,8 @@ static int register_message_code_statistics(void)
}
/* Make sure everything is zeroed out */
- memset(in_message_code_stats, 0, number_of_message_codes);
- memset(out_message_code_stats, 0, number_of_message_codes);
+ memset(in_message_code_stats, 0, sizeof(stat_var*) * number_of_message_codes);
+ memset(out_message_code_stats, 0, sizeof(stat_var*) * number_of_message_codes);
for (i = 0; i < number_of_message_codes; i++)
{