ruby-changes:18645
From: kosaki <ko1@a...>
Date: Thu, 27 Jan 2011 20:32:27 +0900 (JST)
Subject: [ruby-changes:18645] Ruby:r30669 (trunk): * win32/win32.c (rb_w32_spawn): get rid of too huge alloca().
kosaki 2011-01-27 20:31:48 +0900 (Thu, 27 Jan 2011) New Revision: 30669 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30669 Log: * win32/win32.c (rb_w32_spawn): get rid of too huge alloca(). Modified files: trunk/ChangeLog trunk/win32/win32.c Index: ChangeLog =================================================================== --- ChangeLog (revision 30668) +++ ChangeLog (revision 30669) @@ -1,3 +1,7 @@ +Thu Jan 27 20:30:18 2011 KOSAKI Motohiro <kosaki.motohiro@g...> + + * win32/win32.c (rb_w32_spawn): get rid of too huge alloca(). + Thu Jan 27 18:49:53 2011 KOSAKI Motohiro <kosaki.motohiro@g...> * win32/win32.c (open_dir_handle): get rid of too huge alloca(). Index: win32/win32.c =================================================================== --- win32/win32.c (revision 30668) +++ win32/win32.c (revision 30669) @@ -969,6 +969,9 @@ #define STRNDUPA(ptr, src, len) \ (((char *)memcpy(((ptr) = ALLOCA_N(char, (len) + 1)), (src), (len)))[len] = 0) +#define STRNDUPV(ptr, v, src, len) \ + (((char *)memcpy(((ptr) = ALLOCV((v), (len) + 1)), (src), (len)))[len] = 0) + static int check_spawn_mode(int mode) { @@ -1114,6 +1117,7 @@ WCHAR *wcmd, *wshell; rb_pid_t ret; VALUE v = 0; + VALUE v2 = 0; if (check_spawn_mode(mode)) return -1; @@ -1153,14 +1157,14 @@ } if ((unsigned char)*prog == quote) { len = prog++ - cmd - 1; - STRNDUPA(p, cmd + 1, len); + STRNDUPV(p, v2, cmd + 1, len); shell = p; break; } if (quote) continue; if (ISSPACE(*prog) || strchr("<>|*?\"", *prog)) { len = prog - cmd; - STRNDUPA(p, cmd, len); + STRNDUPV(p, v2, cmd, len); shell = p; break; } @@ -1176,7 +1180,7 @@ p = fbuf; } else if (shell != p && strchr(shell, '/')) { - STRNDUPA(p, shell, len); + STRNDUPV(p, v2, shell, len); shell = p; } if (p) translate_char(p, '/', '\\'); @@ -1198,6 +1202,7 @@ wcmd = cmd ? acp_to_wstr(cmd, NULL) : NULL; if (v) ALLOCV_END(v); wshell = shell ? acp_to_wstr(shell, NULL) : NULL; + if (v2) ALLOCV_END(v2); ret = child_result(CreateChild(wcmd, wshell, NULL, NULL, NULL, NULL), mode); free(wshell); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/