diff options
| author | Bernard Xiong <[email protected]> | 2020-06-11 06:52:53 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-06-11 06:52:53 +0800 |
| commit | 8d11b9b822c46526ea300b130aa83d4ce703ff06 (patch) | |
| tree | c6252ac034bc2dbf71938fda423c08e080a1d0ec | |
| parent | b92c2652d5c75c6c65fbfa604d4b109196b1c41d (diff) | |
| parent | 822df76f8e6d3b96d93bca327bcf896b97840662 (diff) | |
Merge pull request #3674 from DavidLin1577/patch-9
[lwip]Fixed a memset bug in ethernetif.c
| -rw-r--r-- | components/net/lwip-1.4.1/src/netif/ethernetif.c | 5 | ||||
| -rw-r--r-- | components/net/lwip-2.0.2/src/netif/ethernetif.c | 5 | ||||
| -rwxr-xr-x | components/net/lwip-2.1.0/src/netif/ethernetif.c | 5 |
3 files changed, 6 insertions, 9 deletions
diff --git a/components/net/lwip-1.4.1/src/netif/ethernetif.c b/components/net/lwip-1.4.1/src/netif/ethernetif.c index 75f86d75d8..d31ea813bc 100644 --- a/components/net/lwip-1.4.1/src/netif/ethernetif.c +++ b/components/net/lwip-1.4.1/src/netif/ethernetif.c @@ -443,16 +443,15 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_ #if LWIP_NETIF_HOSTNAME #define LWIP_HOSTNAME_LEN 16 char *hostname = RT_NULL; - netif = (struct netif*) rt_malloc (sizeof(struct netif) + LWIP_HOSTNAME_LEN); + netif = (struct netif*) rt_calloc (1, sizeof(struct netif) + LWIP_HOSTNAME_LEN); #else - netif = (struct netif*) rt_malloc (sizeof(struct netif)); + netif = (struct netif*) rt_calloc (1, sizeof(struct netif)); #endif if (netif == RT_NULL) { rt_kprintf("malloc netif failed\n"); return -RT_ERROR; } - rt_memset(netif, 0, sizeof(struct netif)); /* set netif */ dev->netif = netif; diff --git a/components/net/lwip-2.0.2/src/netif/ethernetif.c b/components/net/lwip-2.0.2/src/netif/ethernetif.c index be16da7ad3..2fa528aa0d 100644 --- a/components/net/lwip-2.0.2/src/netif/ethernetif.c +++ b/components/net/lwip-2.0.2/src/netif/ethernetif.c @@ -494,16 +494,15 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_ #if LWIP_NETIF_HOSTNAME #define LWIP_HOSTNAME_LEN 16 char *hostname = RT_NULL; - netif = (struct netif*) rt_malloc (sizeof(struct netif) + LWIP_HOSTNAME_LEN); + netif = (struct netif*) rt_calloc (1, sizeof(struct netif) + LWIP_HOSTNAME_LEN); #else - netif = (struct netif*) rt_malloc (sizeof(struct netif)); + netif = (struct netif*) rt_calloc (1, sizeof(struct netif)); #endif if (netif == RT_NULL) { rt_kprintf("malloc netif failed\n"); return -RT_ERROR; } - rt_memset(netif, 0, sizeof(struct netif)); /* set netif */ dev->netif = netif; diff --git a/components/net/lwip-2.1.0/src/netif/ethernetif.c b/components/net/lwip-2.1.0/src/netif/ethernetif.c index 55ffaa89df..637b025790 100755 --- a/components/net/lwip-2.1.0/src/netif/ethernetif.c +++ b/components/net/lwip-2.1.0/src/netif/ethernetif.c @@ -490,16 +490,15 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_ #if LWIP_NETIF_HOSTNAME #define LWIP_HOSTNAME_LEN 16 char *hostname = RT_NULL; - netif = (struct netif*) rt_malloc (sizeof(struct netif) + LWIP_HOSTNAME_LEN); + netif = (struct netif*) rt_calloc (1, sizeof(struct netif) + LWIP_HOSTNAME_LEN); #else - netif = (struct netif*) rt_malloc (sizeof(struct netif)); + netif = (struct netif*) rt_calloc (1, sizeof(struct netif)); #endif if (netif == RT_NULL) { rt_kprintf("malloc netif failed\n"); return -RT_ERROR; } - rt_memset(netif, 0, sizeof(struct netif)); /* set netif */ dev->netif = netif; |
