Commit 9711fa06 authored by Tom Lane's avatar Tom Lane

Fix undersized result buffer in pset_quoted_string().

The malloc request was 1 byte too small for the worst-case output.
This seems relatively unlikely to cause any problems in practice,
as the worst case only occurs if the input string contains no
characters other than single-quote or newline, and even then
malloc alignment padding would probably save the day.  But it's
definitely a bug.

David Rowley
parent a4523c5a
...@@ -2711,7 +2711,7 @@ pset_bool_string(bool val) ...@@ -2711,7 +2711,7 @@ pset_bool_string(bool val)
static char * static char *
pset_quoted_string(const char *str) pset_quoted_string(const char *str)
{ {
char *ret = pg_malloc(strlen(str) * 2 + 2); char *ret = pg_malloc(strlen(str) * 2 + 3);
char *r = ret; char *r = ret;
*r++ = '\''; *r++ = '\'';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment