From 8a4930e3faffedf0c392de1f03508b816fa2244d Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 23 May 2016 14:16:40 -0400 Subject: Fix latent crash in do_text_output_multiline(). do_text_output_multiline() would fail (typically with a null pointer dereference crash) if its input string did not end with a newline. Such cases do not arise in our current sources; but it certainly could happen in future, or in extension code's usage of the function, so we should fix it. To fix, replace "eol += len" with "eol = text + len". While at it, make two cosmetic improvements: mark the input string const, and rename the argument from "text" to "txt" to dodge pgindent strangeness (since "text" is a typedef name). Even though this problem is only latent at present, it seems like a good idea to back-patch the fix, since it's a very simple/safe patch and it's not out of the realm of possibility that we might in future back-patch something that expects sane behavior from do_text_output_multiline(). Per report from Hao Lee. Report: --- src/include/executor/executor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/include/executor') diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h index 44fac278a49..39521ed08e3 100644 --- a/src/include/executor/executor.h +++ b/src/include/executor/executor.h @@ -284,7 +284,7 @@ typedef struct TupOutputState extern TupOutputState *begin_tup_output_tupdesc(DestReceiver *dest, TupleDesc tupdesc); extern void do_tup_output(TupOutputState *tstate, Datum *values, bool *isnull); -extern void do_text_output_multiline(TupOutputState *tstate, char *text); +extern void do_text_output_multiline(TupOutputState *tstate, const char *txt); extern void end_tup_output(TupOutputState *tstate); /* -- cgit v1.2.3