From 8e08d249dba92b87eead4c6b8c0a9bc5924aa22c Mon Sep 17 00:00:00 2001 From: Thomas Faber Date: Tue, 2 Apr 2013 12:53:30 +0000 Subject: [PATCH] =?UTF-8?q?[CRT]=20-=20Fix=20stat64=5Fto=5Fstat=20macro=20?= =?UTF-8?q?definition.=20Patch=20by=20V=C3=ADctor=20Mart=C3=ADnez.=20-=20F?= =?UTF-8?q?ix=20out-of-memory=20error=20cases=20in=20environment=20functio?= =?UTF-8?q?ns.=20-=20Spotted=20by=20PVS-Studio=20CORE-7039=20#resolve?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit svn path=/trunk/; revision=58642 --- reactos/lib/sdk/crt/misc/environ.c | 12 ++++++------ reactos/lib/sdk/crt/stdio/stat.c | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/reactos/lib/sdk/crt/misc/environ.c b/reactos/lib/sdk/crt/misc/environ.c index 343d8a3d412..24481939017 100644 --- a/reactos/lib/sdk/crt/misc/environ.c +++ b/reactos/lib/sdk/crt/misc/environ.c @@ -1,4 +1,4 @@ -/* +/* * environ.c * * ReactOS MSVCRT.DLL Compatibility Library @@ -64,11 +64,11 @@ int BlockEnvToEnvironA(void) { if ((*envptr = malloc(len)) == NULL) { - for (envptr--; envptr >= _environ; envptr--); + for (envptr--; envptr >= _environ; envptr--) free(*envptr); FreeEnvironmentStringsA(environment_strings); free(_environ); - __initenv = _environ = NULL; + __initenv = _environ = NULL; return -1; } memcpy(*envptr++, ptr, len); @@ -116,11 +116,11 @@ int BlockEnvToEnvironW(void) { if ((*envptr = malloc(len * sizeof(wchar_t))) == NULL) { - for (envptr--; envptr >= _wenviron; envptr--); + for (envptr--; envptr >= _wenviron; envptr--) free(*envptr); FreeEnvironmentStringsW(environment_strings); free(_wenviron); - __winitenv = _wenviron = NULL; + __winitenv = _wenviron = NULL; return -1; } memcpy(*envptr++, ptr, len * sizeof(wchar_t)); @@ -168,7 +168,7 @@ char **DuplicateEnvironment(char **original_environment, int wide) *newenvptr = _strdup(*envptr++); if (*newenvptr == NULL) { - for (newenvptr--; newenvptr >= newenv; newenvptr--); + for (newenvptr--; newenvptr >= newenv; newenvptr--) free(*newenvptr); free(newenv); return original_environment; diff --git a/reactos/lib/sdk/crt/stdio/stat.c b/reactos/lib/sdk/crt/stdio/stat.c index 39df882ed34..e72df1d96f2 100644 --- a/reactos/lib/sdk/crt/stdio/stat.c +++ b/reactos/lib/sdk/crt/stdio/stat.c @@ -2,6 +2,7 @@ #include #define stat64_to_stat(buf64, buf) \ + do { \ buf->st_dev = (buf64)->st_dev; \ buf->st_ino = (buf64)->st_ino; \ buf->st_mode = (buf64)->st_mode; \ @@ -13,6 +14,7 @@ buf->st_atime = (time_t)(buf64)->st_atime; \ buf->st_mtime = (time_t)(buf64)->st_mtime; \ buf->st_ctime = (time_t)(buf64)->st_ctime; \ + } while (0) int CDECL _tstat(const _TCHAR* path, struct _stat * buf) {