Date: Mon, 15 Jan 2018 17:27:43 +0000 (UTC) From: Eitan Adler <eadler@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r328008 - head/usr.bin/units Message-ID: <201801151727.w0FHRhpU068523@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: eadler Date: Mon Jan 15 17:27:43 2018 New Revision: 328008 URL: https://svnweb.freebsd.org/changeset/base/328008 Log: units(1): units(1) free savescr in error condition too CID: 978392 Reviewed by: des MFC After: 1 week Modified: head/usr.bin/units/units.c Modified: head/usr.bin/units/units.c ============================================================================== --- head/usr.bin/units/units.c Mon Jan 15 16:58:07 2018 (r328007) +++ head/usr.bin/units/units.c Mon Jan 15 17:27:43 2018 (r328008) @@ -354,6 +354,7 @@ addunit(struct unittype * theunit, const char *toadd, num = atof(item); if (!num) { zeroerror(); + free(savescr); return 1; } if (doingtop ^ flip) { @@ -366,6 +367,7 @@ addunit(struct unittype * theunit, const char *toadd, 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, num = atof(item); if (!num) { zeroerror(); + free(savescr); return 1; } if (doingtop ^ flip) { @@ -401,9 +404,12 @@ addunit(struct unittype * theunit, const char *toadd, 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"); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201801151727.w0FHRhpU068523>