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: [PATCH] - pa/pa.c


Jeffrey A Law wrote:
> 
>   In message <200011291600.eATG0uD89638@dis.dis.com>you write:
>   > 2000-11-29  Mark Klein  <mklein@dis.com>
>   >
>   >         * pa/pa.c (hppa_encode_label): len must consider "@".
> Already beat you to it, I checked in a fix for that bug about a week
> ago :-)
that looks wrong to me, it'll still wander off the end

  const char *str = XSTR (sym, 0);
  int len = strlen (str);
  char *newstr = alloca (len + 1);	<-- what about the NUL too?

  if (str[0] == '*')
    *newstr++ = *str++;			<-- why copy & inc newstr, when there is no
					 -- record of the target string start?

I attach what I suspect is intended, (untested code)

nathan
-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2000-11-30  Nathan Sidwell  <nathan@codesourcery.com>

	* config/pa/pa.c (hppa_encode_label): Remember the NUL too.

Index: config/pa/pa.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/pa/pa.c,v
retrieving revision 1.86
diff -c -3 -p -r1.86 pa.c
*** pa.c	2000/11/30 06:41:29	1.86
--- pa.c	2000/11/30 09:20:52
*************** hppa_encode_label (sym)
*** 5929,5946 ****
       rtx sym;
  {
    const char *str = XSTR (sym, 0);
!   int len = strlen (str);
!   char *newstr = alloca (len + 1);
  
!   if (str[0] == '*')
!     *newstr++ = *str++;
!   strcpy (newstr + 1, str);
!   *newstr = '@';
! 
!   /* Prepending '@' increases the length of the string.  That's important
!      to note since we're going to allocate persistent storage for the
!      new string.  */
!   len++;
  
    XSTR (sym,0) = ggc_alloc_string (newstr, len);
  }
--- 5929,5942 ----
       rtx sym;
  {
    const char *str = XSTR (sym, 0);
!   int len = strlen (str) + 2;
!   char *newstr = alloca (len);
!   char *ptr = newstr;
  
!   if (*str == '*')
!     *ptr++ = *str++;
!   *ptr++ = '@';
!   strcpy (ptr, str);
  
    XSTR (sym,0) = ggc_alloc_string (newstr, len);
  }

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