Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 1276 invoked from network); 10 Sep 2007 19:59:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Sep 2007 19:59:38 -0000 Received: (qmail 47561 invoked by uid 500); 10 Sep 2007 19:59:31 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 47539 invoked by uid 500); 10 Sep 2007 19:59:31 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 47530 invoked by uid 99); 10 Sep 2007 19:59:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Sep 2007 12:59:31 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Sep 2007 19:59:37 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 1E8F11A9832; Mon, 10 Sep 2007 12:59:17 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r574352 - /harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c Date: Mon, 10 Sep 2007 19:59:16 -0000 To: commits@harmony.apache.org From: hindessm@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070910195917.1E8F11A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: hindessm Date: Mon Sep 10 12:59:16 2007 New Revision: 574352 URL: http://svn.apache.org/viewvc?rev=574352&view=rev Log: Fixed some memory leaks. Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c?rev=574352&r1=574351&r2=574352&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c (original) +++ harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c Mon Sep 10 12:59:16 2007 @@ -295,15 +295,25 @@ remote_addr.sin_port = 0; remote_addr.sin_addr.s_addr = 0; address = malloc(sizeof(jbyte)*4); + if (NULL == address) { + goto clean; + } bzero(address,sizeof(jbyte)*4); } else { if(AF_INET != remote_addr.sin_family || length != sizeof(struct sockaddr)) { return NULL; } address = malloc(sizeof(jbyte)*4); + if (NULL == address) { + goto clean; + } memcpy (address, &(remote_addr.sin_addr.s_addr), 4); } sock = malloc(sizeof(hysocket_struct)); + /* TODO: where is sock free'd? */ + if (NULL == sock) { + goto clean; + } sock->sock = socket; sock->family = AF_INET; @@ -314,10 +324,12 @@ //socket channel_class = (*env)->FindClass(env,"org/apache/harmony/nio/internal/SocketChannelImpl"); if(NULL == channel_class) { + free(sock); goto clean; } channel_object = getJavaNioChannelsSocketChannelImplObj(env,channel_class); if(NULL == channel_object) { + free(sock); goto clean; } // new and set FileDescript @@ -340,6 +352,8 @@ (*env)->SetBooleanField(env,channel_object, bound_field,jtrue); } } else { + // sock isn't used on this code path so we should free it + free(sock); //serverSocket channel_class = (*env)->FindClass(env,"org/apache/harmony/nio/internal/ServerSocketChannelImpl"); if(NULL == channel_class) { @@ -378,10 +392,12 @@ // new DatagramChannel channel_class = (*env)->FindClass(env,"org/apache/harmony/nio/internal/DatagramChannelImpl"); if(NULL == channel_class) { + free(sock); goto clean; } channel_object = getJavaNioChannelsSocketChannelImplObj(env,channel_class); if(NULL == channel_object) { + free(sock); goto clean; } // new and set FileDescript @@ -395,10 +411,8 @@ (*env)->SetBooleanField(env,channel_object, bound_field,jtrue); } } -clean: + clean: free(address); free(localAddr); return channel_object; } - -