Commit 5db3a782 authored by Yuguo Zhang's avatar Yuguo Zhang
Browse files

ecl_open_stream, close invalid fd cause crash on windows platform.

actually, the build process will terminated when loading
cmp/cmpos-features.lsp

related function is:

(with-open-file (s fc :direction :output :if-exists :overwrite
                      :if-does-not-exists :create)

it's a MS feature called security-enhanced CRT.
parent 2283656b
......@@ -5146,7 +5146,7 @@ ecl_open_stream(cl_object filename, enum ecl_smmode smm, cl_object if_exists,
fd = safe_open(fname, O_WRONLY|O_CREAT, mode);
unlikely_if (fd < 0) FEcannot_open(filename);
safe_close(fd);
exists = 1;
fd = -1;
}
switch (smm) {
case ecl_smm_probe:
......@@ -5198,7 +5198,8 @@ ecl_open_stream(cl_object filename, enum ecl_smmode smm, cl_object if_exists,
if (file_kind == @':fifo') {
fp = safe_fdopen(fd, OPEN_R);
} else {
safe_close(fd);
if (fd >= 0)
safe_close(fd);
fp = safe_fopen(fname, OPEN_R);
}
break;
......@@ -5207,7 +5208,8 @@ ecl_open_stream(cl_object filename, enum ecl_smmode smm, cl_object if_exists,
if (file_kind == @':fifo') {
fp = safe_fdopen(fd, OPEN_RW);
} else {
safe_close(fd);
if (fd >= 0)
safe_close(fd);
fp = safe_fopen(fname, OPEN_RW);
}
break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment