[monit-dev] [monit] r343 committed - getaddrinfo allocate and freeaddrinfo is required to avoid memleak

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[monit-dev] [monit] r343 committed - getaddrinfo allocate and freeaddrinfo is required to avoid memleak

monit-2
Revision: 343
Author:   [hidden email]
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;
  }


_______________________________________________
monit-dev mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/monit-dev