source{3,4}/torture/smbiconv.c(main): fixed file descriptor leak.
authorSlava Semushin <php-coder@altlinux.ru>
Sat, 23 May 2009 13:51:53 +0000 (20:51 +0700)
committerKarolin Seeger <kseeger@samba.org>
Tue, 26 May 2009 07:39:54 +0000 (09:39 +0200)
File descriptor leaks only when we use file instead of stdout.

Found by cppcheck:
[./source3/torture/smbiconv.c:219]: (error) Resource leak: out
[./source4/torture/smbiconv.c:211]: (error) Resource leak: out
(cherry picked from commit 61cca8aa5f5e3ad665c3b1acfab20802dd0f3f3a)

source3/torture/smbiconv.c
source4/torture/smbiconv.c

index 72fbdc470fe9172640d4ecf0e0fdcca1eda1829f..47353d2a94320019061f3cb1ecf06a0d40dd4fcd 100644 (file)
@@ -216,6 +216,7 @@ int main(int argc, char *argv[])
        cd = smb_iconv_open(to, from);
        if (cd == (smb_iconv_t)-1) {
                DEBUG(0,("unable to find from or to encoding, exiting...\n"));
+               if (out != stdout) fclose(out);
                return 1;
        }
 
index 4eece66bdf6b8b63b9c71fa99bf853ca624f962d..173f37175bfa0e2ffec5270b352fc7ae1e4d4eb2 100644 (file)
@@ -208,6 +208,7 @@ int main(int argc, char *argv[])
        cd = smb_iconv_open_ex(tctx, to, from, lp_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true));
        if((int)cd == -1) {
                DEBUG(0,("unable to find from or to encoding, exiting...\n"));
+               if (out != stdout) fclose(out);
                return 1;
        }