g_malloc -> g_malloc0 where not all struct elements are initialized or

when combined with memset.

Change-Id: I5148a65bee6d4d00c140113ffb1e228adefae93f
Reviewed-on: https://code.wireshark.org/review/20251
Reviewed-by: Jörg Mayer <jmayer@loplof.de>
This commit is contained in:
Joerg Mayer 2017-02-22 19:04:07 +01:00 committed by Jörg Mayer
parent 936a4c1eb9
commit 785a0d8e75
2 changed files with 2 additions and 3 deletions

View File

@ -607,7 +607,7 @@ airpcap_driver_fake_if_info_new(void)
ad = airpcap_if_open(if_info->name, ebuf);
if (ad)
{
fake_if_info = (airpcap_if_info_t *)g_malloc(sizeof (airpcap_if_info_t));
fake_if_info = (airpcap_if_info_t *)g_malloc0(sizeof (airpcap_if_info_t));
fake_if_info->name = g_strdup(if_info->name);
fake_if_info->description = g_strdup(if_info->description);
fake_if_info->loopback = FALSE;

View File

@ -159,10 +159,9 @@ get_interface_list(int *err, char **err_str)
lastlen = 0;
len = 100 * sizeof(struct ifreq);
for ( ; ; ) {
buf = (char *)g_malloc(len);
buf = (char *)g_malloc0(len);
ifc.ifc_len = len;
ifc.ifc_buf = buf;
memset (buf, 0, len);
if (ioctl(sock, SIOCGIFCONF, &ifc) < 0) {
if (errno != EINVAL || lastlen != 0) {
if (err_str != NULL) {