From: Andreas Schneider Date: Wed, 20 Feb 2013 08:23:37 +0000 (+0100) Subject: s4-client: Don't leak file descriptor. X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=b91a20f704363374bc37aaa75e5d2c80f7997017;p=mat%2Fsamba.git s4-client: Don't leak file descriptor. Reviewed-by: Alexander Bokovoy --- diff --git a/source4/client/client.c b/source4/client/client.c index 1dc5b6dd01..5e8f5ca8ae 100644 --- a/source4/client/client.c +++ b/source4/client/client.c @@ -722,6 +722,7 @@ static int do_get(struct smbclient_context *ctx, char *rname, const char *p_lnam start = lseek(handle, 0, SEEK_END); if (start == -1) { d_printf("Error seeking local file\n"); + close(handle); return 1; } } @@ -741,6 +742,9 @@ static int do_get(struct smbclient_context *ctx, char *rname, const char *p_lnam NT_STATUS_IS_ERR(smbcli_getattrE(ctx->cli->tree, fnum, &attr, &size, NULL, NULL, NULL))) { d_printf("getattrib: %s\n",smbcli_errstr(ctx->cli->tree)); + if (newhandle) { + close(handle); + } return 1; } @@ -750,6 +754,9 @@ static int do_get(struct smbclient_context *ctx, char *rname, const char *p_lnam if(!(data = (uint8_t *)malloc(read_size))) { d_printf("malloc fail for size %d\n", read_size); smbcli_close(ctx->cli->tree, fnum); + if (newhandle) { + close(handle); + } return 1; }