diff options
author | Ken Sharp <ken.sharp@artifex.com> | 2013-08-16 14:00:43 +0100 |
---|---|---|
committer | Chris Liddell <chris.liddell@artifex.com> | 2013-08-16 14:46:17 +0100 |
commit | 397abe5622f0a1a9963617fbf1509015563be6fc (patch) | |
tree | 191506b27f10f8e38f448d61fcf14651d69a53a4 | |
parent | 8b5a86bad386569f921d0322bf113fa82b3d4529 (diff) | |
download | ghostpdl-397abe5622f0a1a9963617fbf1509015563be6fc.tar.gz |
Address gp_wgetv not finding *any* environment variables unless compiled with GS_NO_UTF8
The string being passed in as the 'name' was a regular 1 byte C char array.
But _wgetenv expects to be given a wide character string to find and
treats the argument as such. This mean environment variables never matched.
This commit mimics the code for the registry variables, and converts the
name to a wchar before passing to _wgetenv.
CLUSTER_UNTESTED
-rw-r--r-- | gs/base/gp_wgetv.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/gs/base/gp_wgetv.c b/gs/base/gp_wgetv.c index a25988851..6cf6e6df7 100644 --- a/gs/base/gp_wgetv.c +++ b/gs/base/gp_wgetv.c @@ -170,7 +170,18 @@ gp_getenv(const char *name, char *ptr, int *plen) return -1; } #else - const wchar_t *str = _wgetenv(name); + wchar_t *wname; + wchar_t *str; + + wname = malloc(utf8_to_wchar(NULL, name)*sizeof(wchar_t)); + if (wname == NULL) { + return -1; + } + utf8_to_wchar(wname, name); + + str = _wgetenv(wname); + + free(wname); if (str) { /* wchar_to_utf8 returns INCLUDING terminator */ |