summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authoreadler <eadler@FreeBSD.org>2018-01-22 04:15:12 +0000
committereadler <eadler@FreeBSD.org>2018-01-22 04:15:12 +0000
commit5bae443fd0fdbe61367e6ed85c1c3a1cb42f661c (patch)
tree82b59884d5a388410394f335d7fb92ceb881becb /usr.bin
parent5bd2e2067bc1afc46a507050c97e87f31c8c44d5 (diff)
downloadFreeBSD-src-5bae443fd0fdbe61367e6ed85c1c3a1cb42f661c.zip
FreeBSD-src-5bae443fd0fdbe61367e6ed85c1c3a1cb42f661c.tar.gz
MFC r328008:
units(1) free savescr in error condition too CID: 978392
Diffstat (limited to 'usr.bin')
-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 d5dd843..bff203fb 100644
--- a/usr.bin/units/units.c
+++ b/usr.bin/units/units.c
@@ -352,6 +352,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) {
@@ -364,6 +365,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) {
@@ -378,6 +380,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) {
@@ -399,9 +402,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");
}
OpenPOWER on IntegriCloud