diff options
| -rw-r--r-- | opentracker.c | 3 | ||||
| -rw-r--r-- | ot_vector.c | 3 |
2 files changed, 2 insertions, 4 deletions
diff --git a/opentracker.c b/opentracker.c index 065a1ea..eb97b42 100644 --- a/opentracker.c +++ b/opentracker.c | |||
| @@ -217,11 +217,10 @@ static void handle_accept(const int64_t serversocket) { | |||
| 217 | 217 | ||
| 218 | socket_set_blocking((int)sock, 0); | 218 | socket_set_blocking((int)sock, 0); |
| 219 | 219 | ||
| 220 | if (!(cookie = (struct http_data *)malloc(sizeof(struct http_data)))) { | 220 | if (!(cookie = (struct http_data *)calloc(1, sizeof(struct http_data)))) { |
| 221 | close((int)sock); | 221 | close((int)sock); |
| 222 | continue; | 222 | continue; |
| 223 | } | 223 | } |
| 224 | memset(cookie, 0, sizeof(struct http_data)); | ||
| 225 | memcpy(cookie->ip, ip, sizeof(ot_ip6)); | 224 | memcpy(cookie->ip, ip, sizeof(ot_ip6)); |
| 226 | cookie->interest = EVENT_IN; | 225 | cookie->interest = EVENT_IN; |
| 227 | 226 | ||
diff --git a/ot_vector.c b/ot_vector.c index a56d55b..8310634 100644 --- a/ot_vector.c +++ b/ot_vector.c | |||
| @@ -208,10 +208,9 @@ void vector_redistribute_buckets(ot_peerlist *peer_list, size_t peer_size) { | |||
| 208 | return; | 208 | return; |
| 209 | 209 | ||
| 210 | /* Assume near perfect distribution */ | 210 | /* Assume near perfect distribution */ |
| 211 | bucket_list_new = malloc(num_buckets_new * sizeof(ot_vector)); | 211 | bucket_list_new = calloc(1, num_buckets_new * sizeof(ot_vector)); |
| 212 | if (!bucket_list_new) | 212 | if (!bucket_list_new) |
| 213 | return; | 213 | return; |
| 214 | memset(bucket_list_new, 0, num_buckets_new * sizeof(ot_vector)); | ||
| 215 | 214 | ||
| 216 | bucket_size_new = OT_VECTOR_MIN_MEMBERS; | 215 | bucket_size_new = OT_VECTOR_MIN_MEMBERS; |
| 217 | while (bucket_size_new * num_buckets_new < peer_list->peer_count) | 216 | while (bucket_size_new * num_buckets_new < peer_list->peer_count) |
