summaryrefslogtreecommitdiff
path: root/lib/libc/yp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/yp')
-rw-r--r--lib/libc/yp/yp_first.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/libc/yp/yp_first.c b/lib/libc/yp/yp_first.c
index afc8676f0b7..3e24f39ef95 100644
--- a/lib/libc/yp/yp_first.c
+++ b/lib/libc/yp/yp_first.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: yp_first.c,v 1.8 2005/08/05 13:02:16 espie Exp $ */
+/* $OpenBSD: yp_first.c,v 1.9 2009/06/07 03:33:36 schwarze Exp $ */
/*
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@theos.com>
* All rights reserved.
@@ -74,16 +74,14 @@ again:
}
if (!(r = ypprot_err(yprkv.stat))) {
*outkeylen = yprkv.key.keydat_len;
- if ((*outkey = malloc(*outkeylen + 1)) == NULL)
+ *outvallen = yprkv.val.valdat_len;
+ if ((*outkey = malloc(*outkeylen + 1)) == NULL ||
+ (*outval = malloc(*outvallen + 1)) == NULL) {
+ free(*outkey);
r = YPERR_RESRC;
- else {
+ } else {
(void)memcpy(*outkey, yprkv.key.keydat_val, *outkeylen);
(*outkey)[*outkeylen] = '\0';
- }
- *outvallen = yprkv.val.valdat_len;
- if ((*outval = malloc(*outvallen + 1)) == NULL)
- r = YPERR_RESRC;
- else {
(void)memcpy(*outval, yprkv.val.valdat_val, *outvallen);
(*outval)[*outvallen] = '\0';
}