nwrap: Fix memory leak when getline() is used.
authorRobin Hack <hack.robin@gmail.com>
Thu, 8 Oct 2015 09:36:33 +0000 (11:36 +0200)
committerMichael Adam <obnox@samba.org>
Mon, 11 Jan 2016 11:25:28 +0000 (12:25 +0100)
getline() allocates memory even if return code is < 0.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
lib/nss_wrapper/nss_wrapper.c

index bf51ec2d89696eff575be21e9a1842ae205b814b..2759cd7a472c24fe4f92142e92d04448d7d120ae 100644 (file)
@@ -1705,6 +1705,7 @@ static bool nwrap_parse_file(struct nwrap_cache *nwrap)
        do {
                n = getline(&line, &len, nwrap->fp);
                if (n < 0) {
+                       SAFE_FREE(line);
                        if (feof(nwrap->fp)) {
                                break;
                        }