bug-inetutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory leak in ifconfig


From: Alfred M. Szmidt
Subject: Re: Memory leak in ifconfig
Date: Sun, 09 Jan 2022 05:11:16 -0500

How about this patch?

Would you like to try and patch the other bugs you found?

2022-01-09  Alfred M. Szmidt  <ams@gnu.org>

        * ifconfig/system/linux.c (system_parse_opt_set_txqlen)
        (linux_if_nameindex): Call xmalloc instead of malloc.

diff --git a/ifconfig/system/linux.c b/ifconfig/system/linux.c
index 5f914b88..8f3f0f4a 100644
--- a/ifconfig/system/linux.c
+++ b/ifconfig/system/linux.c
@@ -690,7 +690,7 @@ system_parse_opt_set_txqlen (struct ifconfig *ifp, char 
*arg)
 
   if (!(ifp->valid & IF_VALID_SYSTEM))
     {
-      ifp->system = malloc (sizeof (struct system_ifconfig));
+      ifp->system = xmalloc (sizeof (struct system_ifconfig));
       if (!ifp->system)
        error (EXIT_FAILURE, errno,
               "can't get memory for system interface configuration");
@@ -945,7 +945,7 @@ linux_if_nameindex (void)
       }
     while (it);
 
-    idx = malloc (n * sizeof (*idx));
+    idx = xmalloc (n * sizeof (*idx));
     if (idx == NULL)
       {
         int saved_errno = errno;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]