diff --git a/ChangeLog b/ChangeLog index 336addfc0c..bc710ba736 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Thu Jan 27 18:49:53 2011 KOSAKI Motohiro + + * win32/win32.c (open_dir_handle): get rid of too huge alloca(). + Thu Jan 27 18:34:58 2011 KOSAKI Motohiro * file.c (w32_io_info): get rid of too huge alloca(). diff --git a/win32/win32.c b/win32/win32.c index f2bffa6481..a287749173 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -1654,12 +1654,13 @@ open_dir_handle(const WCHAR *filename, WIN32_FIND_DATAW *fd) WCHAR *scanname; WCHAR *p; int len; + VALUE v; // // Create the search pattern // len = lstrlenW(filename); - scanname = ALLOCA_N(WCHAR, len + sizeof(wildcard) / sizeof(WCHAR)); + scanname = ALLOCV_N(WCHAR, v, len + sizeof(wildcard) / sizeof(WCHAR)); lstrcpyW(scanname, filename); p = CharPrevW(scanname, scanname + len); if (*p == L'/' || *p == L'\\' || *p == L':') @@ -1671,6 +1672,7 @@ open_dir_handle(const WCHAR *filename, WIN32_FIND_DATAW *fd) // do the FindFirstFile call // fh = FindFirstFileW(scanname, fd); + ALLOCV_END(v); if (fh == INVALID_HANDLE_VALUE) { errno = map_errno(GetLastError()); } @@ -1799,7 +1801,6 @@ rb_w32_opendir(const char *filename) errno = ENOTDIR; return NULL; } - fh = open_dir_handle(wpath, &fd); free(wpath); return opendir_internal(fh, &fd);