8000203: File descriptor leak in src/solaris/native/java/net/net_util_md.c
authorchegar
Wed, 24 Oct 2012 21:20:40 +0100
changeset 14320 d5be8d19b3ec
parent 14319 0b9fd764d40d
child 14321 7f9f265ac11e
8000203: File descriptor leak in src/solaris/native/java/net/net_util_md.c Reviewed-by: dsamersoff, khazra, chegar Contributed-by: John Zavgren <john.zavgren@oracle.com>
jdk/src/solaris/native/java/net/net_util_md.c
--- a/jdk/src/solaris/native/java/net/net_util_md.c	Wed Oct 24 20:44:07 2012 +0100
+++ b/jdk/src/solaris/native/java/net/net_util_md.c	Wed Oct 24 21:20:40 2012 +0100
@@ -546,6 +546,7 @@
     char dest_str[40];
     struct in6_addr dest_addr;
     char device[16];
+    struct loopback_route *loRoutesTemp;
 
     if (loRoutes != 0) {
         free (loRoutes);
@@ -606,11 +607,15 @@
             continue;
         } else {
             if (nRoutes == loRoutes_size) {
-                loRoutes = realloc (loRoutes, loRoutes_size *
-                                sizeof (struct loopback_route) * 2);
-                if (loRoutes == 0) {
-                    return ;
+                loRoutesTemp = realloc (loRoutes, loRoutes_size *
+                                        sizeof (struct loopback_route) * 2);
+
+                if (loRoutesTemp == 0) {
+                    free(loRoutes);
+                    fclose (f);
+                    return;
                 }
+                loRoutes=loRoutesTemp;
                 loRoutes_size *= 2;
             }
             memcpy (&loRoutes[nRoutes].addr,&dest_addr,sizeof(struct in6_addr));