[openib-general] [PATCH] leak in *_pingpong.c?

Cain, Brian (GE Healthcare) Brian.Cain at ge.com
Tue Sep 12 14:50:24 PDT 2006


Be gentle, it's my first patch submission.  :)

The following is untested, but it looks like it's probably pretty
trivial.


Index: examples/rc_pingpong.c
===================================================================
--- examples/rc_pingpong.c	(revision 9442)
+++ examples/rc_pingpong.c	(working copy)
@@ -143,6 +143,7 @@
 
 	asprintf(&service, "%d", port);
 	n = getaddrinfo(servername, service, &hints, &res);
+	free(service);
 
 	if (n < 0) {
 		fprintf(stderr, "%s for %s:%d\n", gai_strerror(n),
servername, port);
@@ -209,6 +210,7 @@
 
 	asprintf(&service, "%d", port);
 	n = getaddrinfo(NULL, service, &hints, &res);
+	free(service);
 
 	if (n < 0) {
 		fprintf(stderr, "%s for port %d\n", gai_strerror(n),
port);
Index: examples/srq_pingpong.c
===================================================================
--- examples/srq_pingpong.c	(revision 9442)
+++ examples/srq_pingpong.c	(working copy)
@@ -154,6 +154,7 @@
 
 	asprintf(&service, "%d", port);
 	n = getaddrinfo(servername, service, &hints, &res);
+	free(service);
 
 	if (n < 0) {
 		fprintf(stderr, "%s for %s:%d\n", gai_strerror(n),
servername, port);
@@ -233,6 +234,7 @@
 
 	asprintf(&service, "%d", port);
 	n = getaddrinfo(NULL, service, &hints, &res);
+	free(service);
 
 	if (n < 0) {
 		fprintf(stderr, "%s for port %d\n", gai_strerror(n),
port);
Index: examples/uc_pingpong.c
===================================================================
--- examples/uc_pingpong.c	(revision 9442)
+++ examples/uc_pingpong.c	(working copy)
@@ -131,6 +131,7 @@
 
 	asprintf(&service, "%d", port);
 	n = getaddrinfo(servername, service, &hints, &res);
+	free(service);
 
 	if (n < 0) {
 		fprintf(stderr, "%s for %s:%d\n", gai_strerror(n),
servername, port);
@@ -197,6 +198,7 @@
 
 	asprintf(&service, "%d", port);
 	n = getaddrinfo(NULL, service, &hints, &res);
+	free(service);
 
 	if (n < 0) {
 		fprintf(stderr, "%s for port %d\n", gai_strerror(n),
port);
Index: examples/ud_pingpong.c
===================================================================
--- examples/ud_pingpong.c	(revision 9442)
+++ examples/ud_pingpong.c	(working copy)
@@ -132,6 +132,7 @@
 
 	asprintf(&service, "%d", port);
 	n = getaddrinfo(servername, service, &hints, &res);
+	free(service);
 
 	if (n < 0) {
 		fprintf(stderr, "%s for %s:%d\n", gai_strerror(n),
servername, port);
@@ -198,6 +199,7 @@
 
 	asprintf(&service, "%d", port);
 	n = getaddrinfo(NULL, service, &hints, &res);
+	free(service);
 
 	if (n < 0) {
 		fprintf(stderr, "%s for port %d\n", gai_strerror(n),
port);

--
-Brian 




More information about the general mailing list