Skip to content

Commit

Permalink
use proper calloc, not wrongly sized malloc array for media_list
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowman committed May 29, 2016
1 parent fff7ecf commit 0b7f4bd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions media.c
Expand Up @@ -426,9 +426,9 @@ conf_media_status(FILE *output, int s, char *ifname)
if (ifmr.ifm_count == 0)
return(0);

media_list = (u_int64_t *)malloc(ifmr.ifm_count * sizeof(int));
media_list = calloc(ifmr.ifm_count, sizeof(*media_list));
if (media_list == NULL) {
printf("%% conf_media_status: malloc: %s\n", strerror(errno));
printf("%% conf_media_status: calloc: %s\n", strerror(errno));
return(0);
}
ifmr.ifm_ulist = media_list;
Expand Down Expand Up @@ -472,9 +472,9 @@ media_status(int s, char *ifname, char *delim)
return;
}

media_list = (u_int64_t *)malloc(ifmr.ifm_count * sizeof(int));
media_list = calloc(ifmr.ifm_count, sizeof(*media_list));
if (media_list == NULL) {
printf("%% media_status: malloc: %s\n", strerror(errno));
printf("%% media_status: calloc: %s\n", strerror(errno));
return;
}
ifmr.ifm_ulist = media_list;
Expand Down Expand Up @@ -547,9 +547,9 @@ media_supported(int s, char *ifname, char *hdr_delim, char *body_delim)
return;
}

media_list = (u_int64_t *)malloc(ifmr.ifm_count * sizeof(int));
media_list = calloc(ifmr.ifm_count, sizeof(*media_list));
if (media_list == NULL) {
printf("%% media_status: malloc: %s\n", strerror(errno));
printf("%% media_status: calloc: %s\n", strerror(errno));
return;
}
ifmr.ifm_ulist = media_list;
Expand Down

0 comments on commit 0b7f4bd

Please sign in to comment.