mirror of
https://github.com/reactos/reactos.git
synced 2025-04-20 20:36:35 +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
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* 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
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -40,6 +40,7 @@ SetUserEnvironmentVariable (LPVOID *Environment,
|
||||||
UNICODE_STRING DstValue;
|
UNICODE_STRING DstValue;
|
||||||
ULONG Length;
|
ULONG Length;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
PVOID Buffer=NULL;
|
||||||
|
|
||||||
if (bExpand)
|
if (bExpand)
|
||||||
{
|
{
|
||||||
|
@ -50,8 +51,9 @@ SetUserEnvironmentVariable (LPVOID *Environment,
|
||||||
|
|
||||||
DstValue.Length = 0;
|
DstValue.Length = 0;
|
||||||
DstValue.MaximumLength = Length;
|
DstValue.MaximumLength = Length;
|
||||||
DstValue.Buffer = LocalAlloc(LPTR,
|
DstValue.Buffer = Buffer = LocalAlloc(LPTR,
|
||||||
Length);
|
Length);
|
||||||
|
|
||||||
if (DstValue.Buffer == NULL)
|
if (DstValue.Buffer == NULL)
|
||||||
{
|
{
|
||||||
DPRINT1("LocalAlloc() failed\n");
|
DPRINT1("LocalAlloc() failed\n");
|
||||||
|
@ -66,6 +68,7 @@ SetUserEnvironmentVariable (LPVOID *Environment,
|
||||||
{
|
{
|
||||||
DPRINT1("RtlExpandEnvironmentStrings_U() failed (Status %lx)\n", Status);
|
DPRINT1("RtlExpandEnvironmentStrings_U() failed (Status %lx)\n", Status);
|
||||||
DPRINT1("Length %lu\n", Length);
|
DPRINT1("Length %lu\n", Length);
|
||||||
|
if (Buffer) LocalFree(Buffer);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,6 +83,7 @@ SetUserEnvironmentVariable (LPVOID *Environment,
|
||||||
if (!GetShortPathNameW(DstValue.Buffer, ShortName, MAX_PATH))
|
if (!GetShortPathNameW(DstValue.Buffer, ShortName, MAX_PATH))
|
||||||
{
|
{
|
||||||
DPRINT1("GetShortPathNameW() failed (Error %lu)\n", GetLastError());
|
DPRINT1("GetShortPathNameW() failed (Error %lu)\n", GetLastError());
|
||||||
|
if (Buffer) LocalFree(Buffer);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,10 +101,7 @@ SetUserEnvironmentVariable (LPVOID *Environment,
|
||||||
&Name,
|
&Name,
|
||||||
&DstValue);
|
&DstValue);
|
||||||
|
|
||||||
if (bExpand)
|
if (Buffer) LocalFree(Buffer);
|
||||||
{
|
|
||||||
LocalFree(DstValue.Buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue