diff options
Diffstat (limited to 'usr.bin/units/units.c')
-rw-r--r-- | usr.bin/units/units.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/usr.bin/units/units.c b/usr.bin/units/units.c index ced240b9c16..16aad03dd9b 100644 --- a/usr.bin/units/units.c +++ b/usr.bin/units/units.c @@ -1,4 +1,4 @@ -/* $OpenBSD: units.c,v 1.9 2003/07/02 01:57:15 deraadt Exp $ */ +/* $OpenBSD: units.c,v 1.10 2004/12/01 16:41:07 pat Exp $ */ /* $NetBSD: units.c,v 1.6 1996/04/06 06:01:03 thorpej Exp $ */ /* @@ -183,6 +183,7 @@ readunits(char *userfile) lineptr += len + 1; if (!strlen(lineptr)) { readerror(linenum); + free(prefixtable[prefixcount].prefixname); continue; } lineptr += strspn(lineptr, " \n\t"); @@ -208,6 +209,7 @@ readunits(char *userfile) lineptr += strspn(lineptr, " \n\t"); if (!strlen(lineptr)) { readerror(linenum); + free(unittable[unitcount].uname); continue; } len = strcspn(lineptr, "\n\t"); @@ -332,6 +334,7 @@ addunit(struct unittype *theunit, char *toadd, int flip) num = atof(item); if (!num) { zeroerror(); + free(savescr); return 1; } if (doingtop ^ flip) @@ -341,6 +344,7 @@ addunit(struct unittype *theunit, char *toadd, int flip) num = atof(divider + 1); if (!num) { zeroerror(); + free(savescr); return 1; } if (doingtop ^ flip) @@ -351,6 +355,7 @@ addunit(struct unittype *theunit, char *toadd, int flip) num = atof(item); if (!num) { zeroerror(); + free(savescr); return 1; } if (doingtop ^ flip) @@ -368,8 +373,12 @@ addunit(struct unittype *theunit, char *toadd, int flip) item[strlen(item) - 1] = 0; } for (; repeat; repeat--) - if (addsubunit(doingtop ^ flip ? theunit->numerator : theunit->denominator, item)) + if (addsubunit(doingtop ^ flip + ? theunit->numerator + : theunit->denominator, item)) { + free(savescr); return 1; + } } item = strtok(NULL, " *\t/\n"); } |