summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorJan Dubois <jand@activestate.com>2007-01-04 04:20:21 -0800
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2007-01-05 07:47:08 +0000
commitae6198af6119a45e6060c5903f4eddcd7b0f9ade (patch)
tree7995fefdcdfce737f2d5309c2129663ec4dd4d36 /win32
parente163f9a0cad0e6bc632cba9a82e10b83f046f88d (diff)
downloadperl-ae6198af6119a45e6060c5903f4eddcd7b0f9ade.tar.gz
Add error handling to win32_ansipath
Message-ID: <f2oqp2dbdglim8bda4q1kajt9k3cvpqqga@4ax.com> p4raw-id: //depot/perl@29689
Diffstat (limited to 'win32')
-rw-r--r--win32/win32.c42
1 files changed, 23 insertions, 19 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 01621274f0..4a90d0a02b 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -1616,11 +1616,14 @@ win32_longpath(char *path)
static void
out_of_memory()
{
- dTHX;
- /* Can't use PerlIO to write as it allocates memory */
- PerlLIO_write(PerlIO_fileno(Perl_error_log),
- PL_no_mem, strlen(PL_no_mem));
- my_exit(1);
+ if (PL_curinterp) {
+ dTHX;
+ /* Can't use PerlIO to write as it allocates memory */
+ PerlLIO_write(PerlIO_fileno(Perl_error_log),
+ PL_no_mem, strlen(PL_no_mem));
+ my_exit(1);
+ }
+ exit(1);
}
/* The win32_ansipath() function takes a Unicode filename and converts it
@@ -1655,21 +1658,22 @@ win32_ansipath(const WCHAR *widename)
WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, widename, widelen,
name, len, NULL, &use_default);
if (use_default) {
- WCHAR *shortname;
DWORD shortlen = GetShortPathNameW(widename, NULL, 0);
- shortname = win32_malloc(shortlen*sizeof(WCHAR));
- if (!shortname)
- out_of_memory();
- shortlen = GetShortPathNameW(widename, shortname, shortlen)+1;
-
- len = WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, shortname, shortlen,
- NULL, 0, NULL, NULL);
- name = win32_realloc(name, len);
- if (!name)
- out_of_memory();
- WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, shortname, shortlen,
- name, len, NULL, NULL);
- win32_free(shortname);
+ if (shortlen) {
+ WCHAR *shortname = win32_malloc(shortlen*sizeof(WCHAR));
+ if (!shortname)
+ out_of_memory();
+ shortlen = GetShortPathNameW(widename, shortname, shortlen)+1;
+
+ len = WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, shortname, shortlen,
+ NULL, 0, NULL, NULL);
+ name = win32_realloc(name, len);
+ if (!name)
+ out_of_memory();
+ WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, shortname, shortlen,
+ name, len, NULL, NULL);
+ win32_free(shortname);
+ }
}
return name;
}