pgpool2.git / summary / log / commit / refs
commit 0b125118baec71e4345bc373f83fc696c64446f8
Author: Tatsuo Ishii <ishii@postgresql.org>
Date: Tue Mar 06 13:22:18 2012 +0000
Make nodeToString() to return null terminated string. Despite the
naming of pool_string family, they never guarantee null terminated
string. So we modify nodeToString() to ensure it returns null
terminated string. This will make nodeToString users more robust.
parser/outfuncs.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/parser/outfuncs.c b/parser/outfuncs.c
index 117ab9ebc..d1a76f86c 100644
--- a/parser/outfuncs.c
+++ b/parser/outfuncs.c
@@ -5611,8 +5611,12 @@ char *
nodeToString(void *obj)
{
String *str;
+ char *p;
str = init_string("");
_outNode(str, obj);
- return str->data;
+ p = palloc(str->len+1);
+ memcpy(p, str->data, str->len);
+ *(p+str->len) = '\0';
+ return p;
}
[parent: ce12a671cda6]