gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CreateProcessW and NSZoneMalloc (Was Re: Build a project with PC in


From: Richard Frith-Macdonald
Subject: Re: CreateProcessW and NSZoneMalloc (Was Re: Build a project with PC in Windows)
Date: Sun, 9 Mar 2014 08:06:51 +0000

On 9 Mar 2014, at 01:32, Germán Arias <address@hidden> wrote:

> 
> According with this:
> 
> http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425%28v=vs.85%29.aspx
> 
> "lpCommandLine [in, out, optional]
> 
> The Unicode version of this function, CreateProcessW, can modify the contents 
> of this string. Therefore, this parameter cannot be a pointer to read-only 
> memory (such as a const variable or a literal string). If this parameter is a 
> constant string, the function may cause an access violation."
> 
> In NSTask (line 1113) this parameter is created with NSZoneMalloc(). As far I 
> understand the size of this data is fixed. So cannot be changed right? Could 
> be this the problem?

No, malloced memory is mutable; the CreateProcessW call is free to change the 
contents of the buffer.
The size of the buffer is fixed, but that's basically the case for *all* 
buffers. You 'change' the size of a buffer by creating a new one and copying 
the contents of the old one to it. So if the CreateProcessW call wanted a 
larger buffer for something, it would simply create one and copy the command 
line data into it.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]