aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/int8.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/adt/int8.c')
-rw-r--r--src/backend/utils/adt/int8.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c
index abba8f1df04..005f68d8539 100644
--- a/src/backend/utils/adt/int8.c
+++ b/src/backend/utils/adt/int8.c
@@ -149,9 +149,16 @@ int8out(PG_FUNCTION_ARGS)
int64 val = PG_GETARG_INT64(0);
char buf[MAXINT8LEN + 1];
char *result;
+ int len;
- pg_lltoa(val, buf);
- result = pstrdup(buf);
+ len = pg_lltoa(val, buf) + 1;
+
+ /*
+ * Since the length is already known, we do a manual palloc() and memcpy()
+ * to avoid the strlen() call that would otherwise be done in pstrdup().
+ */
+ result = palloc(len);
+ memcpy(result, buf, len);
PG_RETURN_CSTRING(result);
}