mirror of
https://github.com/reactos/reactos.git
synced 2025-07-04 06:51:22 +00:00
don't free non allocated memory
svn path=/trunk/; revision=11872
This commit is contained in:
parent
fa6c7ae193
commit
bcf7f5403f
1 changed files with 37 additions and 36 deletions
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: environment.c,v 1.8 2004/10/10 18:26:33 ekohl Exp $
|
||||
/* $Id: environment.c,v 1.9 2004/11/30 02:26:25 gdalsnes Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
|
@ -40,6 +40,7 @@ SetUserEnvironmentVariable (LPVOID *Environment,
|
|||
UNICODE_STRING DstValue;
|
||||
ULONG Length;
|
||||
NTSTATUS Status;
|
||||
PVOID Buffer=NULL;
|
||||
|
||||
if (bExpand)
|
||||
{
|
||||
|
@ -50,8 +51,9 @@ SetUserEnvironmentVariable (LPVOID *Environment,
|
|||
|
||||
DstValue.Length = 0;
|
||||
DstValue.MaximumLength = Length;
|
||||
DstValue.Buffer = LocalAlloc(LPTR,
|
||||
DstValue.Buffer = Buffer = LocalAlloc(LPTR,
|
||||
Length);
|
||||
|
||||
if (DstValue.Buffer == NULL)
|
||||
{
|
||||
DPRINT1("LocalAlloc() failed\n");
|
||||
|
@ -66,6 +68,7 @@ SetUserEnvironmentVariable (LPVOID *Environment,
|
|||
{
|
||||
DPRINT1("RtlExpandEnvironmentStrings_U() failed (Status %lx)\n", Status);
|
||||
DPRINT1("Length %lu\n", Length);
|
||||
if (Buffer) LocalFree(Buffer);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -80,6 +83,7 @@ SetUserEnvironmentVariable (LPVOID *Environment,
|
|||
if (!GetShortPathNameW(DstValue.Buffer, ShortName, MAX_PATH))
|
||||
{
|
||||
DPRINT1("GetShortPathNameW() failed (Error %lu)\n", GetLastError());
|
||||
if (Buffer) LocalFree(Buffer);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -97,10 +101,7 @@ SetUserEnvironmentVariable (LPVOID *Environment,
|
|||
&Name,
|
||||
&DstValue);
|
||||
|
||||
if (bExpand)
|
||||
{
|
||||
LocalFree(DstValue.Buffer);
|
||||
}
|
||||
if (Buffer) LocalFree(Buffer);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue