aboutsummaryrefslogtreecommitdiff
path: root/contrib/ltree/_ltree_op.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ltree/_ltree_op.c')
-rw-r--r--contrib/ltree/_ltree_op.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/contrib/ltree/_ltree_op.c b/contrib/ltree/_ltree_op.c
index ff8eec793a6..f93d2bb8889 100644
--- a/contrib/ltree/_ltree_op.c
+++ b/contrib/ltree/_ltree_op.c
@@ -215,8 +215,8 @@ _ltree_extract_isparent(PG_FUNCTION_ARGS)
PG_RETURN_NULL();
}
- item = (ltree *) palloc(found->len);
- memcpy(item, found, found->len);
+ item = (ltree *) palloc(VARSIZE(found));
+ memcpy(item, found, VARSIZE(found));
PG_FREE_IF_COPY(la, 0);
PG_FREE_IF_COPY(query, 1);
@@ -238,8 +238,8 @@ _ltree_extract_risparent(PG_FUNCTION_ARGS)
PG_RETURN_NULL();
}
- item = (ltree *) palloc(found->len);
- memcpy(item, found, found->len);
+ item = (ltree *) palloc(VARSIZE(found));
+ memcpy(item, found, VARSIZE(found));
PG_FREE_IF_COPY(la, 0);
PG_FREE_IF_COPY(query, 1);
@@ -261,8 +261,8 @@ _ltq_extract_regex(PG_FUNCTION_ARGS)
PG_RETURN_NULL();
}
- item = (ltree *) palloc(found->len);
- memcpy(item, found, found->len);
+ item = (ltree *) palloc(VARSIZE(found));
+ memcpy(item, found, VARSIZE(found));
PG_FREE_IF_COPY(la, 0);
PG_FREE_IF_COPY(query, 1);
@@ -284,8 +284,8 @@ _ltxtq_extract_exec(PG_FUNCTION_ARGS)
PG_RETURN_NULL();
}
- item = (ltree *) palloc(found->len);
- memcpy(item, found, found->len);
+ item = (ltree *) palloc(VARSIZE(found));
+ memcpy(item, found, VARSIZE(found));
PG_FREE_IF_COPY(la, 0);
PG_FREE_IF_COPY(query, 1);