mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-09 08:10:09 +08:00
Use memcpy() instead of strncpy() for copying into varlena structures.
This commit is contained in:
parent
4f64a07bee
commit
f11aa82d03
contrib
@ -779,7 +779,7 @@ querytree(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
res = (text *) palloc(nrm.cur - nrm.buf + VARHDRSZ);
|
res = (text *) palloc(nrm.cur - nrm.buf + VARHDRSZ);
|
||||||
VARATT_SIZEP(res) = nrm.cur - nrm.buf + VARHDRSZ;
|
VARATT_SIZEP(res) = nrm.cur - nrm.buf + VARHDRSZ;
|
||||||
strncpy(VARDATA(res), nrm.buf, nrm.cur - nrm.buf);
|
memcpy(VARDATA(res), nrm.buf, nrm.cur - nrm.buf);
|
||||||
}
|
}
|
||||||
pfree(q);
|
pfree(q);
|
||||||
|
|
||||||
|
@ -928,7 +928,7 @@ tsquerytree(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
res = (text *) palloc(nrm.cur - nrm.buf + VARHDRSZ);
|
res = (text *) palloc(nrm.cur - nrm.buf + VARHDRSZ);
|
||||||
VARATT_SIZEP(res) = nrm.cur - nrm.buf + VARHDRSZ;
|
VARATT_SIZEP(res) = nrm.cur - nrm.buf + VARHDRSZ;
|
||||||
strncpy(VARDATA(res), nrm.buf, nrm.cur - nrm.buf);
|
memcpy(VARDATA(res), nrm.buf, nrm.cur - nrm.buf);
|
||||||
pfree(q);
|
pfree(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user