diff options
author | Patrick Latifi <pat@cvs.openbsd.org> | 2004-12-01 16:41:08 +0000 |
---|---|---|
committer | Patrick Latifi <pat@cvs.openbsd.org> | 2004-12-01 16:41:08 +0000 |
commit | 9b9fbf109071050f147a9feb4fadae89f7466ba5 (patch) | |
tree | cbf9837841139c59e2952863d6cc15703f88e01f /usr.bin/units/units.c | |
parent | 3cb094fc6eefe3205018976a0c48f124f8336184 (diff) |
* plug memory leaks in the file parser and in the interactive mode parser
ok otto
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"); } |