Test for memory leak in getaddrinfo.
authordrepper <drepper>
Mon, 23 Feb 2004 19:52:27 +0000 (19:52 +0000)
committerdrepper <drepper>
Mon, 23 Feb 2004 19:52:27 +0000 (19:52 +0000)
posix/bug-ga2.c [new file with mode: 0644]

diff --git a/posix/bug-ga2.c b/posix/bug-ga2.c
new file mode 100644 (file)
index 0000000..5ea759b
--- /dev/null
@@ -0,0 +1,30 @@
+/* Test case by Sam Varshavchik <mrsam@courier-mta.com>.  */
+#include <mcheck.h>
+#include <netdb.h>
+#include <stdio.h>
+#include <string.h>
+
+int
+main (void)
+{
+  struct addrinfo hints, *res;
+  int i, ret;
+
+  mtrace ();
+  for (i = 0; i < 100; i++)
+    {
+      memset (&hints, 0, sizeof (hints));
+      hints.ai_family = PF_UNSPEC;
+      hints.ai_socktype = SOCK_STREAM;
+
+      ret = getaddrinfo ("www.gnu.org", "http", &hints, &res);
+
+      if (ret)
+       {
+         printf ("%s\n", gai_strerror (ret));
+         return 1;
+       }
+      freeaddrinfo (res);
+    }
+  return 0;
+}