Sorry, meant reply-to-all
---------- Weitergeleitete Nachricht ----------
Subject: Re: CommandLineToArgvW fix Date: Mon, 8 Oct 2001 20:23:57 +0200 From: Malte Starostik malte@kde.org To: eric pouech eric.pouech@wanadoo.fr
Am Monday 08 October 2001 20:08 schrieben Sie:
Malte Starostik wrote:
Don't free cmdline as the return values point into that string. It's the caller's responsibility to GlobalFree() this according to msdn.
I don't understand what you've done. cmdline is a copy of the passed lpCmdLine parameter used for getting the different bits of the argv, so it should be freed however, what's wrong with current implementation (hence your issues) is that when freeing cmdline the argv array points to garbage it means that the argv array and cmdline should be allocated in a single memory block suh that argv[i] points to the part of the string
You're definately right, I mixed up argv with argv[i] there.
wouldn't the (completly untested but) attached patch work better ?
Didn't test it either, will do so somewhen later, looks right to me. -- Malte Starostik PGP: 1024D/D2F3C787 [C138 2121 FAF3 410A 1C2A 27CD 5431 7745 D2F3 C787]
-------------------------------------------------------
On Mon, 8 Oct 2001, Malte Starostik wrote:
Sorry, meant reply-to-all
---------- Weitergeleitete Nachricht ----------
Subject: Re: CommandLineToArgvW fix Date: Mon, 8 Oct 2001 20:23:57 +0200 From: Malte Starostik malte@kde.org To: eric pouech eric.pouech@wanadoo.fr
Am Monday 08 October 2001 20:08 schrieben Sie:
Malte Starostik wrote:
Don't free cmdline as the return values point into that string. It's the caller's responsibility to GlobalFree() this according to msdn.
I don't understand what you've done. cmdline is a copy of the passed lpCmdLine parameter used for getting the different bits of the argv, so it should be freed however, what's wrong with current implementation (hence your issues) is that when freeing cmdline the argv array points to garbage it means that the argv array and cmdline should be allocated in a single memory block suh that argv[i] points to the part of the string
You're definately right, I mixed up argv with argv[i] there.
Here's my take on this. I believe it's a slightly better patch. I tested this in NT4 and there is indeed a single alloc done for the array and the strings. Also, the array does not contain a terminating NULL pointer like I thought. And the lpCmdLine="" case is handled the same way so this patch changes that too. I did not test the patch... yet (recompiling). If I find something wrong I'll send an updated version.
-- Francois Gouget fgouget@free.fr http://fgouget.free.fr/ Any sufficiently advanced Operating System is indistinguishable from Linux