]> granicus.if.org Git - postgresql/commit
Fix latent crash in do_text_output_multiline().
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 23 May 2016 18:16:41 +0000 (14:16 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 23 May 2016 18:16:41 +0000 (14:16 -0400)
commit7b40b2d90f44c1f4ef1bc130bd94decb15826676
treecc6447d06479f55dfbfa1e5dc7e9f8776761ca04
parent57a72661b4e56aab0df1f04d2bd9eaf7da111652
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: <CAGoxFiFPAGyPAJLcFxTB5cGhTW2yOVBDYeqDugYwV4dEd1L_Ag@mail.gmail.com>
src/backend/executor/execTuples.c
src/include/executor/executor.h