From 567ed4e71824e374293e8a05effc1a898af494d8 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 24 Sep 2004 17:42:46 +0000 Subject: [PATCH] r2601: avoid free()ing unallocated memory by mistake (This used to be commit e502b276ae5e4e22e31a522c4d9e346996d6e29f) --- source4/lib/xfile.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source4/lib/xfile.c b/source4/lib/xfile.c index de4cf4b12a7..e01723904f6 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; }