diff options
Diffstat (limited to 'win32/win32.c')
-rw-r--r-- | win32/win32.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/win32/win32.c b/win32/win32.c index 7a4c2852db..7cbfae8a83 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -1564,6 +1564,7 @@ XS(w32_GetShortPathName) { dXSARGS; SV *shortpath; + DWORD len; if(items != 1) croak("usage: Win32::GetShortPathName($longPathName)"); @@ -1571,8 +1572,15 @@ XS(w32_GetShortPathName) shortpath = sv_mortalcopy(ST(0)); SvUPGRADE(shortpath, SVt_PV); /* src == target is allowed */ - if (GetShortPathName(SvPVX(shortpath), SvPVX(shortpath), SvCUR(shortpath))) + do { + len = GetShortPathName(SvPVX(shortpath), + SvPVX(shortpath), + SvLEN(shortpath)); + } while (len >= SvLEN(shortpath) && sv_grow(shortpath,len+1)); + if (len) { + SvCUR_set(shortpath,len); ST(0) = shortpath; + } else ST(0) = &sv_undef; XSRETURN(1); |