From patchwork Sun Sep 27 21:22:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Pluzhnikov X-Patchwork-Id: 523173 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C709B14090B for ; Mon, 28 Sep 2015 07:22:24 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=O935pRHs; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:date:message-id:subject:from:to :cc:content-type; q=dns; s=default; b=ecUF18iFWDdKh0+StvDK2IpwrT vrowhPtqm+gZ5qcpWDO/Q4F+Ppv2pxzRNmNt2OtFC/9VxywJdLTEkvqv2gsAlLQ0 pIPKvllzVLw+Sbqybl5JrbhV/97s4C7wHBOYrxCKKsh7RiZ8yGj5CCVUqZsn4nPe Mpcl4zzDNHnGTL+04= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:date:message-id:subject:from:to :cc:content-type; s=default; bh=CwtQHtUwQ0EpG5xUJ5O16+98S0g=; b= O935pRHsrrQxa0IrY8jikyCVzo/Rfbgyi7HfkgygNkJCQ3oIKm/pKrK2BLerVcEb AOPBh8S/JzdxRO7jmUkBIoU4u9pdp0jvWqtkE1R801SkvKn6ls3mohNXT9QOqbld Y53/JiLfK8kjDTADERD/3TlSmgRoPbFzxbBsi6/EYMw= Received: (qmail 70673 invoked by alias); 27 Sep 2015 21:22:18 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 70663 invoked by uid 89); 27 Sep 2015 21:22:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ob0-f178.google.com MIME-Version: 1.0 X-Received: by 10.60.145.131 with SMTP id su3mr8547112oeb.14.1443388934082; Sun, 27 Sep 2015 14:22:14 -0700 (PDT) Date: Sun, 27 Sep 2015 14:22:13 -0700 Message-ID: Subject: [patch] Fix BZ 19012 -- memory leak on error path in iconv_open From: Paul Pluzhnikov To: GLIBC Devel Cc: Paul Pluzhnikov Greetings, Attached patch fixes the leak, but doesn't add a test case. In order to expose the bug, a partial install (one missing iconvdata/SJIS.so) is required. I am not sure how to write such a test case (or even whether it is truly a bug to leak memory when faced with such a partial install). Thanks, 2015-09-27 Paul Pluzhnikov [BZ #19012] * iconv/gconv_db.c (gen_steps): Clean up on error. diff --git a/iconv/gconv_db.c b/iconv/gconv_db.c index 4e6ec65..bb9a2bd 100644 --- a/iconv/gconv_db.c +++ b/iconv/gconv_db.c @@ -279,6 +279,12 @@ gen_steps (struct derivation_step *best, const char *toset, if (shlib_handle == NULL) { failed = 1; + + /* Don't leak memory. BZ #19012. */ + if (step_cnt == 0) + free (result[step_cnt].__from_name); + free (result[*nsteps - 1].__to_name); + break; }