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]

Re: Use ENCODE_SECTION_INFO and friends on Darwin


On Thu, Jun 07, 2001 at 07:38:51PM -0700, Stan Shebs wrote:
> + 	size_t len = strlen (XSTR (sym_ref, 0));
> + 	size_t newlen = len + 4;
> + 	char *str = alloca (newlen);
> + 
> + 	str[0] = '!';
> + 	str[1] = code;
> + 	str[2] = '_';
> + 	str[3] = '_';
> + 	memcpy (str + 4, XSTR (sym_ref, 0), len + 1);

You're also allocating one too few bytes in your temp buffer.
Move that "+1" up to the strlen line and you'll be fine.


r~


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