summaryrefslogtreecommitdiff
path: root/source3/lib/xfile.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2004-09-24 17:38:23 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:52:47 -0500
commit70ac6b6b55f0423eb9296fbdc7db0d2aa634a601 (patch)
tree797bb60d04f78b9f35cd7678e3aab94b77c7c928 /source3/lib/xfile.c
parentaa62710b2e2aa1a1c7284a9b2704994928581d6b (diff)
downloadsamba-70ac6b6b55f0423eb9296fbdc7db0d2aa634a601.tar.gz
samba-70ac6b6b55f0423eb9296fbdc7db0d2aa634a601.tar.bz2
samba-70ac6b6b55f0423eb9296fbdc7db0d2aa634a601.zip
r2599: avoid free()ing our static unalloceted memory that ends up in memory corruption.
(This used to be commit 557e12d1b593b582ea1157d278bcdde6aba5a879)
Diffstat (limited to 'source3/lib/xfile.c')
-rw-r--r--source3/lib/xfile.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/source3/lib/xfile.c b/source3/lib/xfile.c
index 1534dd855e..da5ec126c1 100644
--- a/source3/lib/xfile.c
+++ b/source3/lib/xfile.c
@@ -135,7 +135,12 @@ int x_fclose(XFILE *f)
memset(f->buf, 0, f->bufsize);
SAFE_FREE(f->buf);
}
- SAFE_FREE(f);
+ /* check the file descriptor given to the function is NOT one of the static
+ * descriptor of this libreary or we will free unallocated memory
+ * --sss */
+ if (f != x_stdin && f != x_stdout && f != x_stderr) {
+ SAFE_FREE(f);
+ }
return ret;
}