cmp fd leak fix

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

cmp fd leak fix

Loganaden Velvindron
Hi All,

From NetBSD:

Plug fd leak. Coverity CID 1624.

Index: src/usr.bin/cmp/special.c
===================================================================
RCS file: /cvs/src/usr.bin/cmp/special.c,v
retrieving revision 1.7
diff -u -p -r1.7 special.c
--- src/usr.bin/cmp/special.c 19 Jan 2011 13:01:25 -0000 1.7
+++ src/usr.bin/cmp/special.c 30 Dec 2013 06:54:05 -0000
@@ -88,6 +88,8 @@ eof: if (ferror(fp1))
  } else
  if (feof(fp2))
  eofmsg(file2);
+ (void)fclose(fp1);
+ (void)fclose(fp2);
  if (dfound)
  exit(DIFF_EXIT);
 }

Reply | Threaded
Open this post in threaded view
|

Re: cmp fd leak fix

Mike Belopuhov-5
On Sun, Dec 29, 2013 at 23:28 -0800, Loganaden Velvindron wrote:
> Hi All,
>
> From NetBSD:
>
> Plug fd leak. Coverity CID 1624.
>

fd leak?  they're "leaking" back to the system.  the function is
not recursive nor it's called in a loop.

> Index: src/usr.bin/cmp/special.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/cmp/special.c,v
> retrieving revision 1.7
> diff -u -p -r1.7 special.c
> --- src/usr.bin/cmp/special.c 19 Jan 2011 13:01:25 -0000 1.7
> +++ src/usr.bin/cmp/special.c 30 Dec 2013 06:54:05 -0000
> @@ -88,6 +88,8 @@ eof: if (ferror(fp1))
>   } else
>   if (feof(fp2))
>   eofmsg(file2);
> + (void)fclose(fp1);
> + (void)fclose(fp2);
>   if (dfound)
>   exit(DIFF_EXIT);
>  }
>