summaryrefslogtreecommitdiffstats
path: root/src/lib/krb5/unicode
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2013-02-09 00:43:35 -0500
committerGreg Hudson <ghudson@mit.edu>2013-02-09 00:43:35 -0500
commit7905cd6a2eddbf264242bb2a85f811878b2da7ab (patch)
tree72b4028cbe0e399e1d293e2b718530913f0a2673 /src/lib/krb5/unicode
parent92e2bac0f38f7f60a8fc74b5964357212c4289e1 (diff)
downloadkrb5-7905cd6a2eddbf264242bb2a85f811878b2da7ab.tar.gz
krb5-7905cd6a2eddbf264242bb2a85f811878b2da7ab.tar.xz
krb5-7905cd6a2eddbf264242bb2a85f811878b2da7ab.zip
Add and use k5memdup, k5memdup0 helpers
Add k5-int.h static functions to duplicate byte ranges, optionally with a trailing zero byte, and set an error code like k5alloc does. Use them where they would shorten existing code.
Diffstat (limited to 'src/lib/krb5/unicode')
-rw-r--r--src/lib/krb5/unicode/ucstr.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/lib/krb5/unicode/ucstr.c b/src/lib/krb5/unicode/ucstr.c
index 625c9de1c4..38d8d47d02 100644
--- a/src/lib/krb5/unicode/ucstr.c
+++ b/src/lib/krb5/unicode/ucstr.c
@@ -160,13 +160,9 @@ krb5int_utf8_normalize(
if (i == len) {
newdata->length = len;
- newdata->data = malloc(newdata->length + 1);
- if (newdata->data == NULL) {
- retval = ENOMEM;
+ newdata->data = k5memdup0(s, len, &retval);
+ if (newdata->data == NULL)
goto cleanup;
- }
- memcpy(newdata->data, s, len);
- newdata->data[len] = '\0';
*newdataptr = newdata;
return 0;
}