Return-Path: X-Original-To: apmail-zookeeper-commits-archive@www.apache.org Delivered-To: apmail-zookeeper-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 98B699E7B for ; Mon, 25 Jun 2012 18:08:19 +0000 (UTC) Received: (qmail 96542 invoked by uid 500); 25 Jun 2012 18:08:19 -0000 Delivered-To: apmail-zookeeper-commits-archive@zookeeper.apache.org Received: (qmail 96520 invoked by uid 500); 25 Jun 2012 18:08:19 -0000 Mailing-List: contact commits-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ Delivered-To: mailing list commits@zookeeper.apache.org Received: (qmail 96512 invoked by uid 99); 25 Jun 2012 18:08:19 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Jun 2012 18:08:19 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Jun 2012 18:08:18 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 5FE4E238890B for ; Mon, 25 Jun 2012 18:07:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1353689 - in /zookeeper/branches/branch-3.3: CHANGES.txt src/c/src/zk_hashtable.c Date: Mon, 25 Jun 2012 18:07:57 -0000 To: commits@zookeeper.apache.org From: michim@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120625180758.5FE4E238890B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: michim Date: Mon Jun 25 18:07:56 2012 New Revision: 1353689 URL: http://svn.apache.org/viewvc?rev=1353689&view=rev Log: ZOOKEEPER-1163. Memory leak in zk_hashtable.c:do_insert_watcher_object() (Anupam Chanda via michim) Modified: zookeeper/branches/branch-3.3/CHANGES.txt zookeeper/branches/branch-3.3/src/c/src/zk_hashtable.c Modified: zookeeper/branches/branch-3.3/CHANGES.txt URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.3/CHANGES.txt?rev=1353689&r1=1353688&r2=1353689&view=diff ============================================================================== --- zookeeper/branches/branch-3.3/CHANGES.txt (original) +++ zookeeper/branches/branch-3.3/CHANGES.txt Mon Jun 25 18:07:56 2012 @@ -22,6 +22,9 @@ BUGFIXES: ZOOKEEPER-1431. zkpython async calls leak memory (Kapil Thangavelu and Andre Cruz via henryr) + ZOOKEEPER-1163. Memory leak in zk_hashtable.c:do_insert_watcher_object() + (Anupam Chanda via michim) + Release 3.3.5 - 2012-03-18 Backward compatible changes: Modified: zookeeper/branches/branch-3.3/src/c/src/zk_hashtable.c URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.3/src/c/src/zk_hashtable.c?rev=1353689&r1=1353688&r2=1353689&view=diff ============================================================================== --- zookeeper/branches/branch-3.3/src/c/src/zk_hashtable.c (original) +++ zookeeper/branches/branch-3.3/src/c/src/zk_hashtable.c Mon Jun 25 18:07:56 2012 @@ -189,8 +189,12 @@ static int do_insert_watcher_object(zk_h res=hashtable_insert(ht->ht,strdup(path),create_watcher_object_list(wo)); assert(res); }else{ - /* path already exists; check if the watcher already exists */ - res = add_to_list(&wl, wo, 1); + /* + * Path already exists; check if the watcher already exists. + * Don't clone the watcher since it's allocated on the heap --- avoids + * a memory leak and saves a clone operation (calloc + copy). + */ + res = add_to_list(&wl, wo, 0); } return res; }