From 537bcb48fab24896ff2a53a22052c2cbebcca5d9 Mon Sep 17 00:00:00 2001 From: Hartmut Birr Date: Wed, 13 Jul 2005 17:59:37 +0000 Subject: [PATCH] Fixed the allocation of the buffer for the environment variable in ProcessInput. svn path=/trunk/; revision=16557 --- reactos/subsys/system/cmd/cmd.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/reactos/subsys/system/cmd/cmd.c b/reactos/subsys/system/cmd/cmd.c index 1c220d9cd5b..4666b290308 100644 --- a/reactos/subsys/system/cmd/cmd.c +++ b/reactos/subsys/system/cmd/cmd.c @@ -1061,18 +1061,19 @@ ProcessInput (BOOL bFlag) } else { - evar = malloc ( size * sizeof(TCHAR)); + evar = malloc ( 512 * sizeof(TCHAR)); if (evar==NULL) return 1; - size = GetEnvironmentVariable (ip, evar, size); - if (size!=0) + size = GetEnvironmentVariable (ip, evar, 512); + if (size > 512) { evar = realloc(evar,size * sizeof(TCHAR) ); - if (evar!=NULL) + if (evar==NULL) { - size = GetEnvironmentVariable (ip, evar, size); + return 1; } + size = GetEnvironmentVariable (ip, evar, size); } if (size)