This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Avoid strndup in gcc.c (PR bootstrap/67363)


As described in the PR, this patch

	https://gcc.gnu.org/ml/gcc-patches/2015-08/msg01549.html

broke bootstrap on a couple of platforms that lack strndup in libc.
Fixed as follows, matching other uses of xstrndup in the gcc
subdirectory.

Bootstrapped on i386-pc-solaris2.10, installed on mainline as obvious.

	Rainer


2015-08-31  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	PR bootstrap/67363
	* gcc.c (env_manager::xput): Replace strndup by xstrndup.

# HG changeset patch
# Parent  1b9570b3c98bf549aba6dee203d37955e96d744d
Avoid strndup in gcc.c (PR bootstrap/67363)

diff --git a/gcc/gcc.c b/gcc/gcc.c
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -123,7 +123,7 @@ env_manager::xput (const char *string)
       gcc_assert (equals);
 
       struct kv kv;
-      kv.m_key = strndup (string, equals - string);
+      kv.m_key = xstrndup (string, equals - string);
       const char *cur_value = ::getenv (kv.m_key);
       if (m_debug)
 	fprintf (stderr, "saving old value: %s\n",cur_value);
-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]