diff --git a/native/envvar-cmdline.cpp b/native/envvar-cmdline.cpp index 57f9bc6..fd01ff2 100644 --- a/native/envvar-cmdline.cpp +++ b/native/envvar-cmdline.cpp @@ -184,7 +184,8 @@ JNIEXPORT jstring JNICALL Java_org_jvnet_winp_Native_getCmdLineAndEnvVars( } int cmdLineLen = lstrlen(pszCmdLine); - size_t envSize = info.RegionSize; + size_t envSize = info.RegionSize - ((char*)pEnvStr - (char*)info.BaseAddress); + auto_localmem buf((cmdLineLen + 1/*for \0*/) * 2 + envSize); if(!buf) { reportError(pEnv, "Buffer allocation failed");