summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2005-11-12 00:49:56 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2005-11-12 00:49:56 +0000
commitd9ee9e6e519f0f37c003c101bdda37d610154f3c (patch)
tree9027bb9468e31b3b1dbfe4fc7cffedcbed801998
parent6c2ade453d7df6c3b0cecbfb9c994cd0a335849d (diff)
use asprintf instead; dhill@mindcry.org
-rw-r--r--bin/expr/expr.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/bin/expr/expr.c b/bin/expr/expr.c
index 83bf979c3c9..52635e42204 100644
--- a/bin/expr/expr.c
+++ b/bin/expr/expr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: expr.c,v 1.15 2003/06/11 23:42:12 deraadt Exp $ */
+/* $OpenBSD: expr.c,v 1.16 2005/11/12 00:49:55 deraadt Exp $ */
/* $NetBSD: expr.c,v 1.3.6.1 1996/06/04 20:41:47 cgd Exp $ */
/*
@@ -157,17 +157,13 @@ void
to_string(struct val *vp)
{
char *tmp;
- size_t len;
if (vp->type == string)
return;
- len = 25;
- tmp = malloc(len);
- if (tmp == NULL) {
+ if (asprintf(&tmp, "%d", vp->u.i) == -1)
err(3, NULL);
- }
- snprintf(tmp, len, "%d", vp->u.i);
+
vp->type = string;
vp->u.s = tmp;
}