diff options
author | eadler <eadler@FreeBSD.org> | 2018-01-22 04:15:12 +0000 |
---|---|---|
committer | eadler <eadler@FreeBSD.org> | 2018-01-22 04:15:12 +0000 |
commit | 5bae443fd0fdbe61367e6ed85c1c3a1cb42f661c (patch) | |
tree | 82b59884d5a388410394f335d7fb92ceb881becb /usr.bin | |
parent | 5bd2e2067bc1afc46a507050c97e87f31c8c44d5 (diff) | |
download | FreeBSD-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.c | 10 |
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"); } |