monit-dev
[Top][All Lists]
Advanced

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

[monit-dev] [monit] r343 committed - getaddrinfo allocate and freeaddrin


From: monit
Subject: [monit-dev] [monit] r343 committed - getaddrinfo allocate and freeaddrinfo is required to avoid memleak
Date: Wed, 23 Mar 2011 14:33:44 +0000

Revision: 343
Author:   address@hidden
Date:     Wed Mar 23 07:33:11 2011
Log:      getaddrinfo allocate and freeaddrinfo is required to avoid memleak


http://code.google.com/p/monit/source/detail?r=343

Modified:
 /trunk/util.c

=======================================
--- /trunk/util.c       Wed Mar 23 03:15:53 2011
+++ /trunk/util.c       Wed Mar 23 07:33:11 2011
@@ -2013,7 +2013,7 @@
 int Util_getfqdnhostname(char *buf, unsigned len) {
   int status;
   char hostname[STRLEN];
-  struct addrinfo hints, *info;
+  struct addrinfo hints, *info = NULL;

   if (gethostname(hostname, sizeof(hostname))) {
     LogError("%s: Error getting hostname -- %s\n", prog, STRERROR);
@@ -2029,7 +2029,8 @@
     snprintf(buf, len, "%s", hostname); // fallback to gethostname()
   } else
     snprintf(buf, len, "%s", info->ai_canonname);
-
+  if (info)
+    freeaddrinfo(info);
   return 0;
 }




reply via email to

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