found resource leaks

View: New views
2 Messages — Rating Filter:   Alert me  

found resource leaks

by Martin Ettl-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

i have checked the sources of the cpio-2.10  library with the static code analysis tool cppcheck. It found little issues:

[cpio-2.10/src/copyin.c:1583]: (error) Resource leak: tty_in
[cpio-2.10/src/copyin.c:1583]: (error) Resource leak: tty_out
[cpio-2.10/src/copyin.c:1583]: (error) Resource leak: rename_in



Take a loop at file copyin.c at line 1583:
....
}

The function ends without flcose the opened file pointers. A possible fix might be :

...
 if(tty_in!=NULL) fclose(tty_in);
 if(tty_out!=NULL) fclose(tty_out);
 if(rename_in!=NULL) fclose(rename_in);
...

Best regards

Ettl Martin







--
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01



Re: found resource leaks

by Sergey Poznyakoff-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Martin,

> [cpio-2.10/src/copyin.c:1583]: (error) Resource leak: tty_in
> [cpio-2.10/src/copyin.c:1583]: (error) Resource leak: tty_out
> [cpio-2.10/src/copyin.c:1583]: (error) Resource leak: rename_in

They will be closed when the program finishes and that happens
right after process_copy_in returns.

Regards,
Sergey