[PATCH] scanner: Close input resource when done to prevent leak

Marek Chalupa mchqwerty at gmail.com
Wed Jul 1 03:13:08 PDT 2015


To be up to good programming practices we should close the input even on
the error paths on lines 1381, 1392 and 1400 (it can be stdin, but on exit
it doesn't matter).
Scanner is sooo leaky, that pedantically closing read-only input file on
every error path may seem a little bit useless, but it is the first nice
step to get rid of the leaks and
errors from whatever tool Denis used to find this leak.

Cheers,
Marek

On Sat, Jun 20, 2015 at 12:54 AM, Bryce Harrington <bryce at osg.samsung.com>
wrote:

> Addresses this error reported by Denis Denisov:
>
>   [src/scanner.c:1415]: (error) Resource leak: input
>
> Signed-off-by: Bryce Harrington <bryce at osg.samsung.com>
> ---
>  src/scanner.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/src/scanner.c b/src/scanner.c
> index 7d8cfb9..2843d85 100644
> --- a/src/scanner.c
> +++ b/src/scanner.c
> @@ -1415,5 +1415,6 @@ int main(int argc, char *argv[])
>                         break;
>         }
>
> +       fclose(input);
>         return 0;
>  }
> --
> 1.9.1
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20150701/55536de8/attachment.html>


More information about the wayland-devel mailing list