summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2004-09-24 17:42:46 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:59:11 -0500
commit567ed4e71824e374293e8a05effc1a898af494d8 (patch)
treee9513c2452f426106f0fe6099b500791eb49ad66
parentdf99e4bb3751560eb74a4a923c4d7510926f5d71 (diff)
downloadsamba-567ed4e71824e374293e8a05effc1a898af494d8.tar.gz
samba-567ed4e71824e374293e8a05effc1a898af494d8.tar.bz2
samba-567ed4e71824e374293e8a05effc1a898af494d8.zip
r2601: avoid free()ing unallocated memory by mistake
(This used to be commit e502b276ae5e4e22e31a522c4d9e346996d6e29f)
-rw-r--r--source4/lib/xfile.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/source4/lib/xfile.c b/source4/lib/xfile.c
index de4cf4b12a..e01723904f 100644
--- a/source4/lib/xfile.c
+++ b/source4/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;
}