changeset 6559:909676adaefd

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>
author chegar
date Wed, 24 Oct 2012 21:20:40 +0100
parents 8e8fcd44b963
children 37a4b4892e8e
files src/solaris/native/java/net/net_util_md.c
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/native/java/net/net_util_md.c	Wed Oct 24 20:44:07 2012 +0100
+++ b/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));