From 3b61d972335c6da98a0ece7060481f7a6d4178eb Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Wed, 16 May 2018 14:03:14 +1000 Subject: [PATCH] Minor alloc cleanup. --- lrzip.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lrzip.c b/lrzip.c index aa27b67a..6db70b29 100644 --- a/lrzip.c +++ b/lrzip.c @@ -1303,7 +1303,8 @@ bool compress_file(rzip_control *control) bool initialise_control(rzip_control *control) { time_t now_t, tdiff; - char *eptr; /* for environment */ + char localeptr[] = "./", *eptr; /* for environment */ + size_t len; memset(control, 0, sizeof(rzip_control)); control->msgout = stderr; @@ -1346,13 +1347,9 @@ bool initialise_control(rzip_control *control) eptr = getenv("TEMPDIR"); if (!eptr) eptr = getenv("TEMP"); - if (!eptr) { - eptr = malloc(3); - if ( eptr == NULL ) - fatal_return(("Failed to allocate for eptr\n"), false); - strcpy(eptr,"./"); - } - size_t len = strlen(eptr); + if (!eptr) + eptr = localeptr; + len = strlen(eptr); control->tmpdir = malloc(len + 2); if (control->tmpdir == NULL)