summaryrefslogtreecommitdiffstats
path: root/source/lib/xfile.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2004-09-24 17:38:23 +0000
committerSimo Sorce <idra@samba.org>2004-09-24 17:38:23 +0000
commit66eb2100c2ebeaa8e997c7dee805b4abfa7fd513 (patch)
treeb8f1004da835f1aafccc477313bf42e748c2b03c /source/lib/xfile.c
parentb8897b969148bd03327b7617be9602d5d0356240 (diff)
downloadsamba-66eb2100c2ebeaa8e997c7dee805b4abfa7fd513.tar.gz
samba-66eb2100c2ebeaa8e997c7dee805b4abfa7fd513.tar.xz
samba-66eb2100c2ebeaa8e997c7dee805b4abfa7fd513.zip
r2599: avoid free()ing our static unalloceted memory that ends up in memory corruption.
Diffstat (limited to 'source/lib/xfile.c')
-rw-r--r--source/lib/xfile.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/source/lib/xfile.c b/source/lib/xfile.c
index 1534dd855e9..da5ec126c1f 100644
--- a/source/lib/xfile.c
+++ b/source/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;
}