From 8fb5a1aceb8a98fd1598a5c821614cbb0e1fa4e6 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 4 Apr 2015 01:00:45 +0000 Subject: stub.c: use argv[0] unchanged * win32/stub.c (stub_sysinit): use argv[0] unchanged and just insert full path name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- win32/stub.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/win32/stub.c b/win32/stub.c index 3960024fc2..9c3659cb96 100644 --- a/win32/stub.c +++ b/win32/stub.c @@ -21,7 +21,7 @@ stub_sysinit(int *argc, char ***argv) for (i = 1; i < ac; ++i) { lenall += strlen(av[i]) + 1; } - av = realloc(av, lenall + (lenexe + 1) * 2 + sizeof(char *) * (i + 2)); + av = realloc(av, lenall + len0 + (lenexe + 1) + sizeof(char *) * (i + 2)); if (!av) { perror("realloc command line"); exit(-1); @@ -29,11 +29,10 @@ stub_sysinit(int *argc, char ***argv) *argv = av; *argc = ++ac; p = (char *)(av + i + 2); - memmove(p + (lenexe + 1) * 2, (char *)(av + ac) + len0, lenall); - memcpy(p, exename, lenexe); - p[lenexe] = '\0'; + memmove(p + len0 + lenexe + 1, (char *)(av + ac) + len0, lenall); + memmove(p, (char *)(av + ac), len0); *av++ = p; - p += lenexe + 1; + p += len0; memcpy(p, exename, lenexe); p[lenexe] = '\0'; *av++ = p; -- cgit v1.2.3