From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id D7F2D3857829 for ; Sun, 27 Jun 2021 17:13:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D7F2D3857829 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-343-X-AavnBuMWezulNxa3BXAQ-1; Sun, 27 Jun 2021 13:13:55 -0400 X-MC-Unique: X-AavnBuMWezulNxa3BXAQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3D7F8100B3AE; Sun, 27 Jun 2021 17:13:54 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-112-228.ams2.redhat.com [10.36.112.228]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 32F3E60C0F; Sun, 27 Jun 2021 17:13:53 +0000 (UTC) From: Florian Weimer To: Siddhesh Poyarekar Cc: schwab@linux-m68k.org, libc-alpha@sourceware.org Subject: Re: [PATCH v2] iconvconfig: Fix multiple issues References: <20210625090128.316837-1-siddhesh@sourceware.org> <87czsagvr6.fsf@oldenburg.str.redhat.com> <6e926fff-7739-bbe0-6e62-5369810217db@sourceware.org> Date: Sun, 27 Jun 2021 19:13:51 +0200 In-Reply-To: <6e926fff-7739-bbe0-6e62-5369810217db@sourceware.org> (Siddhesh Poyarekar's message of "Fri, 25 Jun 2021 14:37:04 +0530") Message-ID: <87o8br2ptc.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Jun 2021 17:13:59 -0000 * Siddhesh Poyarekar: > On 6/25/21 2:35 PM, Florian Weimer via Libc-alpha wrote: >> * Siddhesh Poyarekar: >> >>> @@ -519,11 +520,12 @@ module_compare (const void *p1, const void *p2) >>> /* Create new module record. */ >>> static void >>> new_module (const char *fromname, size_t fromlen, const char *toname, >>> - size_t tolen, const char *directory, >>> + size_t tolen, const char *dir_in, >>> const char *filename, size_t filelen, int cost, size_t need_ext) >>> { >>> struct module *new_module; >>> - size_t dirlen = strlen (directory) + 1; >>> + size_t dirlen = strlen (dir_in) + 1; >>> + const char *directory = xstrdup (dir_in); >> Sorry, why is this copy needed? > > That's the fulldir reference that goes from here into the symtab and > so on. Later once the handle_dir function returns and the cache file > is being written out, this pointer is referenced and by then it has > already been freed. I see, it's returned to the caller via new_module->directory. Apparently we do not free modules, so this doesn't add a new leak. Patch looks okay to me then. Thanks, Florian