Re: pgindent (was Re: [HACKERS] [COMMITTERS] pgsql: Preventive maintenance in advance of pgindent run.) - Mailing list pgsql-hackers

From Tom Lane
Subject Re: pgindent (was Re: [HACKERS] [COMMITTERS] pgsql: Preventive maintenance in advance of pgindent run.)
Date
Msg-id 322.1495328415@sss.pgh.pa.us
Whole thread Raw
In response to Re: pgindent (was Re: [HACKERS] [COMMITTERS] pgsql: Preventive maintenance in advance of pgindent run.)  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: pgindent (was Re: [HACKERS] [COMMITTERS] pgsql: Preventivemaintenance in advance of pgindent run.)  (Piotr Stefaniak <postgres@piotr-stefaniak.me>)
List pgsql-hackers
I wrote:
> Also, I found two places where an overlength comment line is simply busted
> altogether --- notice that a character is missing at the split point:

I found the cause of that: you need to apply this patch:

--- freebsd_indent/pr_comment.c~    2017-05-17 14:59:31.548442801 -0400
+++ freebsd_indent/pr_comment.c    2017-05-20 20:51:16.447332977 -0400
@@ -344,8 +353,8 @@ pr_comment(void)        {            int len = strlen(t_ptr);
-            CHECK_SIZE_COM(len);
-            memmove(e_com, t_ptr, len);
+            CHECK_SIZE_COM(len + 1);
+            memmove(e_com, t_ptr, len + 1);            last_bl = strpbrk(e_com, " \t");            e_com += len;
}
 

As the code stands, the strpbrk call is being applied to a
not-null-terminated string and therefore is sometimes producing an
insane value of last_bl, messing up decisions later in the comment.
Having the memmove include the trailing \0 resolves that.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] bumping HASH_VERSION to 3
Next
From: Amit Kapila
Date:
Subject: Re: [HACKERS] bumping HASH_VERSION to 3