From patchwork Mon Jun 19 16:18:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 777846 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 3wrx454H5tz9s76 for ; Tue, 20 Jun 2017 02:18:45 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="dW6IoMsh"; 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:date:to:subject:mime-version:content-type :content-transfer-encoding:message-id:from; q=dns; s=default; b= x5+M8SD9nPq96FeagGoTyq08G5INNjenex0gMj4Crn4mOnOVMZOw0Qzpz2UZi7Zw v8MkjrF5jsbQlL4X9JX571oQf9osdJOE1iqZoYPGer04pbxnu7u+xzMvk5HW+2Hh ECqpFpUer+rCKyDFIxwLextkapGNUWXqOsQehHTpqvA= 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:date:to:subject:mime-version:content-type :content-transfer-encoding:message-id:from; s=default; bh=zCwmA3 TCa1HjPCA1MGIZZ1XIsX8=; b=dW6IoMshV8lI7v4I97FuqKI6vakm51EOcakDSr dpTjQQkYLcNsaJKgR71BwbGWwIHJCsOYoVox1G5GZxlVVqa4AFvqTW4hu/xz8umB ZvaiX3Wb5GXANzbSC7rsV2kqom39bk48/rkAOPdJRqjn9rARNYHDWMhWRAGq/thp DHaCw= Received: (qmail 80292 invoked by alias); 19 Jun 2017 16:18:33 -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 80207 invoked by uid 89); 19 Jun 2017 16:18:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 728C0C007AC5 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=fweimer@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 728C0C007AC5 Date: Mon, 19 Jun 2017 18:18:33 +0200 To: libc-alpha@sourceware.org Subject: [PATCH] _nl_load_domain: Use calloc instead of alloca User-Agent: Heirloom mailx 12.5 7/5/10 MIME-Version: 1.0 Message-Id: <20170619161833.6D6BC402AEC0E@oldenburg.str.redhat.com> From: fweimer@redhat.com (Florian Weimer) 2017-06-19 Florian Weimer * intl/loadmsgcat.c: Remove alloca support. (_nl_load_domain): Use calloc instead of alloca. diff --git a/intl/loadmsgcat.c b/intl/loadmsgcat.c index 4dd75de..049fc88 100644 --- a/intl/loadmsgcat.c +++ b/intl/loadmsgcat.c @@ -32,29 +32,6 @@ #include #include -#ifdef __GNUC__ -# undef alloca -# define alloca __builtin_alloca -# define HAVE_ALLOCA 1 -#else -# ifdef _MSC_VER -# include -# define alloca _alloca -# else -# if defined HAVE_ALLOCA_H || defined _LIBC -# include -# else -# ifdef _AIX - #pragma alloca -# else -# ifndef alloca -char *alloca (); -# endif -# endif -# endif -# endif -#endif - #include #include @@ -476,15 +453,6 @@ char *alloca (); # define munmap(addr, len) __munmap (addr, len) #endif -/* For those losing systems which don't have `alloca' we have to add - some additional code emulating it. */ -#ifdef HAVE_ALLOCA -# define freea(p) /* nothing */ -#else -# define alloca(n) malloc (n) -# define freea(p) free (p) -#endif - /* For systems that distinguish between text and binary I/O. O_BINARY is usually declared in . */ #if !defined O_BINARY && defined _O_BINARY @@ -982,9 +950,8 @@ _nl_load_domain (struct loaded_l10nfile *domain_file, sysdep_segments = (const struct sysdep_segment *) ((char *) data + W (domain->must_swap, data->sysdep_segments_offset)); - sysdep_segment_values = - (const char **) - alloca (n_sysdep_segments * sizeof (const char *)); + sysdep_segment_values = calloc + (n_sysdep_segments, sizeof (const char *)); for (i = 0; i < n_sysdep_segments; i++) { const char *name = @@ -995,7 +962,7 @@ _nl_load_domain (struct loaded_l10nfile *domain_file, if (!(namelen > 0 && name[namelen - 1] == '\0')) { - freea (sysdep_segment_values); + free (sysdep_segment_values); goto invalid; } @@ -1046,7 +1013,7 @@ _nl_load_domain (struct loaded_l10nfile *domain_file, if (sysdepref >= n_sysdep_segments) { /* Invalid. */ - freea (sysdep_segment_values); + free (sysdep_segment_values); goto invalid; } @@ -1250,7 +1217,7 @@ _nl_load_domain (struct loaded_l10nfile *domain_file, domain->trans_sysdep_tab = NULL; } - freea (sysdep_segment_values); + free (sysdep_segment_values); } else {