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: 8864 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; }