diff options
author | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2013-04-01 16:08:01 +0000 |
---|---|---|
committer | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2013-04-01 16:08:01 +0000 |
commit | 8e1d45009ccf98c3439f72bc78cd5eea1250b829 (patch) | |
tree | 97b83ee8bfdce857d5d9e97d56b99e1ceae8ea35 /usr.bin/sdiff | |
parent | 9c0cc2e6ad734107acf25e4156aa718ef7ee4ee0 (diff) |
Avoid memory leak while parsing diff's output.
ok lteo
Diffstat (limited to 'usr.bin/sdiff')
-rw-r--r-- | usr.bin/sdiff/sdiff.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.bin/sdiff/sdiff.c b/usr.bin/sdiff/sdiff.c index 2aa684e0c2a..33bb6bf0eec 100644 --- a/usr.bin/sdiff/sdiff.c +++ b/usr.bin/sdiff/sdiff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sdiff.c,v 1.28 2009/06/07 13:29:50 ray Exp $ */ +/* $OpenBSD: sdiff.c,v 1.29 2013/04/01 16:08:00 tobias Exp $ */ /* * Written by Raymond Lai <ray@cyth.net>. @@ -740,11 +740,14 @@ parsecmd(FILE *diffpipe, FILE *file1, FILE *file2) default: errx(2, "invalid diff command: %c: %s", cmd, line); } + free(line); /* Skip to next ed line. */ - while (n--) - if (!xfgets(diffpipe)) + while (n--) { + if (!(line = xfgets(diffpipe))) errx(2, "diff ended early"); + free(line); + } return (0); } |