aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/units
diff options
context:
space:
mode:
authorEitan Adler <eadler@FreeBSD.org>2018-01-15 17:27:43 +0000
committerEitan Adler <eadler@FreeBSD.org>2018-01-15 17:27:43 +0000
commit9cd768a17735cba98c4fe80ec76e5bbdcda118c5 (patch)
tree29e7776364a2be4196d9f2d2b818674543b02378 /usr.bin/units
parent2c18ede69116a97ccf2737d238d014875ba1d011 (diff)
downloadsrc-9cd768a17735cba98c4fe80ec76e5bbdcda118c5.tar.gz
src-9cd768a17735cba98c4fe80ec76e5bbdcda118c5.zip
units(1): units(1) free savescr in error condition too
CID: 978392 Reviewed by: des MFC After: 1 week
Notes
Notes: svn path=/head/; revision=328008
Diffstat (limited to 'usr.bin/units')
-rw-r--r--usr.bin/units/units.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/usr.bin/units/units.c b/usr.bin/units/units.c
index 8f7c7081518b..4499d9f3a081 100644
--- a/usr.bin/units/units.c
+++ b/usr.bin/units/units.c
@@ -354,6 +354,7 @@ addunit(struct unittype * theunit, const char *toadd, int flip, int quantity)
num = atof(item);
if (!num) {
zeroerror();
+ free(savescr);
return 1;
}
if (doingtop ^ flip) {
@@ -366,6 +367,7 @@ addunit(struct unittype * theunit, const char *toadd, int flip, int quantity)
num = atof(divider + 1);
if (!num) {
zeroerror();
+ free(savescr);
return 1;
}
if (doingtop ^ flip) {
@@ -380,6 +382,7 @@ addunit(struct unittype * theunit, const char *toadd, int flip, int quantity)
num = atof(item);
if (!num) {
zeroerror();
+ free(savescr);
return 1;
}
if (doingtop ^ flip) {
@@ -401,9 +404,12 @@ addunit(struct unittype * theunit, const char *toadd, int flip, int quantity)
repeat = item[strlen(item) - 1] - '0';
item[strlen(item) - 1] = 0;
}
- for (; repeat; repeat--)
- if (addsubunit(doingtop ^ flip ? theunit->numerator : theunit->denominator, item))
+ for (; repeat; repeat--) {
+ if (addsubunit(doingtop ^ flip ? theunit->numerator : theunit->denominator, item)) {
+ free(savescr);
return 1;
+ }
+ }
}
item = strtok(NULL, " *\t/\n");
}