diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2011-11-05 23:26:11 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2011-11-05 23:26:11 -0700 |
commit | d435df363ff8e2ac5303cb837c9ff2604920ae56 (patch) | |
tree | 8fea2aff6eb5fdfa03c5251cefd8055cc0a58112 /lib.c | |
parent | 6a339b6b889349be35c7822709c253b0e8d10eb0 (diff) | |
download | txr-d435df363ff8e2ac5303cb837c9ff2604920ae56.tar.gz txr-d435df363ff8e2ac5303cb837c9ff2604920ae56.tar.bz2 txr-d435df363ff8e2ac5303cb837c9ff2604920ae56.zip |
* lib.c (env): Fixed inappropriate cut-and-pasted error messages.
Check for failure of GetEnvironmentStringsW, and call
FreeEnvironmentStringsW is called.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -2319,13 +2319,19 @@ val env(void) return env_list = out; #elif HAVE_GETENVIRONMENTSTRINGS wchar_t *env = GetEnvironmentStringsW(); + wchar_t *iter = env; - for (; *env; env += wcslen(env) + 1) - list_collect (ptail, string(env)); + if (iter == 0) + uw_throwf(error_s, lit("out of memory"), nao); + + for (; *iter; iter += wcslen(iter) + 1) + list_collect (ptail, string(iter)); + + FreeEnvironmentStringsW(env); return env_list = out; #else - uw_throwf(error_s, lit("string_extend: overflow"), nao); + uw_throwf(error_s, lit("environment strings not available"), nao); #endif } } |