summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/mruby.h4
-rw-r--r--mrbgems/mruby-io/src/io.c4
2 files changed, 5 insertions, 3 deletions
diff --git a/include/mruby.h b/include/mruby.h
index 114b58cf4..d93874dfa 100644
--- a/include/mruby.h
+++ b/include/mruby.h
@@ -999,8 +999,8 @@ char* mrb_locale_from_utf8(const char *p, int len);
#define mrb_locale_free(p) free(p)
#define mrb_utf8_free(p) free(p)
#else
-#define mrb_utf8_from_locale(p, l) (p)
-#define mrb_locale_from_utf8(p, l) (p)
+#define mrb_utf8_from_locale(p, l) ((char*)p)
+#define mrb_locale_from_utf8(p, l) ((char*)p)
#define mrb_locale_free(p)
#define mrb_utf8_free(p)
#endif
diff --git a/mrbgems/mruby-io/src/io.c b/mrbgems/mruby-io/src/io.c
index b3166b11b..99ddf4e39 100644
--- a/mrbgems/mruby-io/src/io.c
+++ b/mrbgems/mruby-io/src/io.c
@@ -557,6 +557,7 @@ mrb_cloexec_open(mrb_state *mrb, const char *pathname, mrb_int flags, mrb_int mo
{
mrb_value emsg;
int fd, retry = FALSE;
+ char* fname = mrb_locale_from_utf8(pathname, -1);
#ifdef O_CLOEXEC
/* O_CLOEXEC is available since Linux 2.6.23. Linux 2.6.18 silently ignore it. */
@@ -565,7 +566,7 @@ mrb_cloexec_open(mrb_state *mrb, const char *pathname, mrb_int flags, mrb_int mo
flags |= O_NOINHERIT;
#endif
reopen:
- fd = open(pathname, (int)flags, mode);
+ fd = open(fname, (int)flags, mode);
if (fd == -1) {
if (!retry) {
switch (errno) {
@@ -581,6 +582,7 @@ reopen:
mrb_str_modify(mrb, mrb_str_ptr(emsg));
mrb_sys_fail(mrb, RSTRING_PTR(emsg));
}
+ mrb_utf8_free(fname);
if (fd <= 2) {
mrb_fd_cloexec(mrb, fd);