mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-02 03:02:31 +00:00
osproc: fixes a memory leak affecting Windows
This commit is contained in:
@@ -410,13 +410,11 @@ when defined(Windows) and not defined(useNimRtl):
|
||||
result.readDataImpl = hsReadData
|
||||
result.writeDataImpl = hsWriteData
|
||||
|
||||
proc buildCommandLine(a: string, args: openArray[string]): cstring =
|
||||
var res = quoteShell(a)
|
||||
proc buildCommandLine(a: string, args: openArray[string]): string =
|
||||
result = quoteShell(a)
|
||||
for i in 0..high(args):
|
||||
res.add(' ')
|
||||
res.add(quoteShell(args[i]))
|
||||
result = cast[cstring](alloc0(res.len+1))
|
||||
copyMem(result, cstring(res), res.len)
|
||||
result.add(' ')
|
||||
result.add(quoteShell(args[i]))
|
||||
|
||||
proc buildEnv(env: StringTableRef): tuple[str: cstring, len: int] =
|
||||
var L = 0
|
||||
@@ -540,11 +538,13 @@ when defined(Windows) and not defined(useNimRtl):
|
||||
result.errHandle = FileHandle(si.hStdError)
|
||||
|
||||
var cmdl: cstring
|
||||
var cmdRoot: string
|
||||
if poEvalCommand in options:
|
||||
cmdl = command
|
||||
assert args.len == 0
|
||||
else:
|
||||
cmdl = buildCommandLine(command, args)
|
||||
cmdRoot = buildCommandLine(command, args)
|
||||
cmdl = cstring(cmdRoot)
|
||||
var wd: cstring = nil
|
||||
var e = (str: nil.cstring, len: -1)
|
||||
if len(workingDir) > 0: wd = workingDir
|
||||
|
||||
Reference in New Issue
Block a user