• R/O
  • SSH

libctools: Commit

This library contains code that extends and simplifies different operations
for C language based programs.


Commit MetaInfo

Revisióna102e98f17414ef2bebfa8be1bb422b271d37961 (tree)
Tiempo2022-08-30 05:24:33
AutorSergey Gusarov <laborer2008@gmai...>
CommiterSergey Gusarov

Log Message

test_os_io: Fixed crash

Cambiar Resumen

Diferencia incremental

diff -r daf7012d56a8 -r a102e98f1741 src/os/io.c
--- a/src/os/io.c Mon Aug 29 23:24:02 2022 +0300
+++ b/src/os/io.c Mon Aug 29 23:24:33 2022 +0300
@@ -132,7 +132,9 @@
132132 CT_CHECK_PTR_AND_BREAK(name);
133133
134134 // fopenWrapper() do the same things, that's why it's not used here
135- file = fopen(name, "br");
135+
136+ // MSVC++: First mode character must be 'r', 'w' or 'a'
137+ file = fopen(name, "rb");
136138 if (!file)
137139 {
138140 CT_TRACE_ERRORC("fopen() failed");
diff -r daf7012d56a8 -r a102e98f1741 src/std/stdio.c
--- a/src/std/stdio.c Mon Aug 29 23:24:02 2022 +0300
+++ b/src/std/stdio.c Mon Aug 29 23:24:33 2022 +0300
@@ -63,6 +63,11 @@
6363 CT_CHECK_PTR_AND_BREAK(path);
6464 CT_CHECK_PTR_AND_BREAK(mode);
6565
66+#if defined(CT_OS_WINDOWS)
67+ if (!(mode[0] == 'a' || mode[0] == 'r' || mode[0] == 'w'))
68+ CT_TRACE_ERRORN('Invalid first mode characted: %c', mode[0]);
69+#endif
70+
6671 fopenResult = fopen(path, mode);
6772 if (!fopenResult)
6873 CT_TRACE_ERRORC("fopen() for \"%s\" with mode=\"%s\" failed", path, mode);
Show on old repository browser