aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--erts/emulator/beam/erl_bif_port.c2
-rw-r--r--erts/emulator/beam/erl_nif.c3
-rw-r--r--erts/emulator/beam/erl_unicode.c17
-rwxr-xr-xerts/emulator/beam/global.h3
4 files changed, 15 insertions, 10 deletions
diff --git a/erts/emulator/beam/erl_bif_port.c b/erts/emulator/beam/erl_bif_port.c
index 864349491a..f298422267 100644
--- a/erts/emulator/beam/erl_bif_port.c
+++ b/erts/emulator/beam/erl_bif_port.c
@@ -808,7 +808,7 @@ open_port(Process* p, Eterm name, Eterm settings, int *err_typep, int *err_nump)
if (encoding == ERL_FILENAME_WIN_WCHAR) {
encoding = ERL_FILENAME_UTF8;
}
- if ((name_buf = erts_convert_filename_to_encoding(name, NULL, 0, ERTS_ALC_T_TMP,0,1, encoding, NULL))
+ if ((name_buf = erts_convert_filename_to_encoding(name, NULL, 0, ERTS_ALC_T_TMP,0,1, encoding, NULL, 0))
== NULL) {
goto badarg;
}
diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c
index de626ca4e1..dc285b3cf7 100644
--- a/erts/emulator/beam/erl_nif.c
+++ b/erts/emulator/beam/erl_nif.c
@@ -1587,7 +1587,8 @@ BIF_RETTYPE load_nif_2(BIF_ALIST_2)
encoding = ERL_FILENAME_UTF8;
}
lib_name = erts_convert_filename_to_encoding(BIF_ARG_1, NULL, 0,
- ERTS_ALC_T_TMP, 1, 0, encoding, NULL);
+ ERTS_ALC_T_TMP, 1, 0, encoding,
+ NULL, 0);
if (!lib_name) {
BIF_ERROR(BIF_P, BADARG);
}
diff --git a/erts/emulator/beam/erl_unicode.c b/erts/emulator/beam/erl_unicode.c
index 7e3c6681d9..3a968594f3 100644
--- a/erts/emulator/beam/erl_unicode.c
+++ b/erts/emulator/beam/erl_unicode.c
@@ -1990,12 +1990,14 @@ char *erts_convert_filename_to_native(Eterm name, char *statbuf, size_t statbuf_
{
int encoding = erts_get_native_filename_encoding();
return erts_convert_filename_to_encoding(name, statbuf, statbuf_size, alloc_type,
- allow_empty, allow_atom, encoding, used);
+ allow_empty, allow_atom, encoding,
+ used, 0);
}
char *erts_convert_filename_to_encoding(Eterm name, char *statbuf, size_t statbuf_size,
ErtsAlcType_t alloc_type, int allow_empty,
- int allow_atom, int encoding, Sint *used)
+ int allow_atom, int encoding, Sint *used,
+ Uint extra)
{
char* name_buf = NULL;
@@ -2008,13 +2010,14 @@ char *erts_convert_filename_to_encoding(Eterm name, char *statbuf, size_t statbu
}
if (encoding == ERL_FILENAME_WIN_WCHAR) {
need += 2;
+ extra *= 2;
} else {
++need;
}
if (used)
*used = (Sint) need;
- if (need > statbuf_size) {
- name_buf = (char *) erts_alloc(alloc_type, need);
+ if (need+extra > statbuf_size) {
+ name_buf = (char *) erts_alloc(alloc_type, need+extra);
} else {
name_buf = statbuf;
}
@@ -2035,8 +2038,8 @@ char *erts_convert_filename_to_encoding(Eterm name, char *statbuf, size_t statbu
/*Add 0 termination only*/
if (used)
*used = (Sint) size+1;
- if (size+1 > statbuf_size) {
- name_buf = (char *) erts_alloc(alloc_type, size+1);
+ if (size+1+extra > statbuf_size) {
+ name_buf = (char *) erts_alloc(alloc_type, size+1+extra);
} else {
name_buf = statbuf;
}
@@ -2045,7 +2048,7 @@ char *erts_convert_filename_to_encoding(Eterm name, char *statbuf, size_t statbu
} else {
name_buf = erts_convert_filename_to_wchar(bytes, size,
statbuf, statbuf_size,
- alloc_type, used, 0);
+ alloc_type, used, extra);
}
erts_free_aligned_binary_bytes(temp_alloc);
} else {
diff --git a/erts/emulator/beam/global.h b/erts/emulator/beam/global.h
index 94bc1b172a..6e5d352e5b 100755
--- a/erts/emulator/beam/global.h
+++ b/erts/emulator/beam/global.h
@@ -921,7 +921,8 @@ char *erts_convert_filename_to_encoding(Eterm name, char *statbuf,
ErtsAlcType_t alloc_type,
int allow_empty, int allow_atom,
int encoding,
- Sint *used /* out */);
+ Sint *used /* out */,
+ Uint extra);
char* erts_convert_filename_to_wchar(byte* bytes, Uint size,
char *statbuf, size_t statbuf_size,
ErtsAlcType_t alloc_type, Sint* used,