diff options
Diffstat (limited to 'coreutils/expr.c')
-rw-r--r-- | coreutils/expr.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/coreutils/expr.c b/coreutils/expr.c index 0299cc73a..55ae3a969 100644 --- a/coreutils/expr.c +++ b/coreutils/expr.c | |||
@@ -146,12 +146,8 @@ static int null (VALUE *v) | |||
146 | 146 | ||
147 | static void tostring (VALUE *v) | 147 | static void tostring (VALUE *v) |
148 | { | 148 | { |
149 | char *temp; | ||
150 | |||
151 | if (v->type == integer) { | 149 | if (v->type == integer) { |
152 | temp = xmalloc (4 * (sizeof (int) / sizeof (char))); | 150 | bb_asprintf (&(v->u.s), "%d", v->u.i); |
153 | sprintf (temp, "%d", v->u.i); | ||
154 | v->u.s = temp; | ||
155 | v->type = string; | 151 | v->type = string; |
156 | } | 152 | } |
157 | } | 153 | } |
@@ -377,9 +373,7 @@ static VALUE *eval6 (void) | |||
377 | else { | 373 | else { |
378 | v = xmalloc (sizeof(VALUE)); | 374 | v = xmalloc (sizeof(VALUE)); |
379 | v->type = string; | 375 | v->type = string; |
380 | v->u.s = strncpy ((char *) xmalloc (i2->u.i + 1), | 376 | v->u.s = xstrndup(l->u.s + i1->u.i - 1, i2->u.i); |
381 | l->u.s + i1->u.i - 1, i2->u.i); | ||
382 | v->u.s[i2->u.i] = 0; | ||
383 | } | 377 | } |
384 | freev (l); | 378 | freev (l); |
385 | freev (i1); | 379 | freev (i1); |