aboutsummaryrefslogtreecommitdiff
path: root/src/common/stringinfo.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/stringinfo.c')
-rw-r--r--src/common/stringinfo.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/common/stringinfo.c b/src/common/stringinfo.c
index 05b22b5c53c..dc97754a685 100644
--- a/src/common/stringinfo.c
+++ b/src/common/stringinfo.c
@@ -70,10 +70,16 @@ initStringInfo(StringInfo str)
*
* Reset the StringInfo: the data buffer remains valid, but its
* previous content, if any, is cleared.
+ *
+ * Read-only StringInfos as initialized by initReadOnlyStringInfo cannot be
+ * reset.
*/
void
resetStringInfo(StringInfo str)
{
+ /* don't allow resets of read-only StringInfos */
+ Assert(str->maxlen != 0);
+
str->data[0] = '\0';
str->len = 0;
str->cursor = 0;
@@ -284,6 +290,9 @@ enlargeStringInfo(StringInfo str, int needed)
{
int newlen;
+ /* validate this is not a read-only StringInfo */
+ Assert(str->maxlen != 0);
+
/*
* Guard against out-of-range "needed" values. Without this, we can get
* an overflow or infinite loop in the following.