Author: tfaber
Date: Tue Apr 2 12:53:30 2013
New Revision: 58642
URL:
http://svn.reactos.org/svn/reactos?rev=58642&view=rev
Log:
[CRT]
- Fix stat64_to_stat macro definition. Patch by Víctor Martínez.
- Fix out-of-memory error cases in environment functions.
- Spotted by PVS-Studio
CORE-7039 #resolve
Modified:
trunk/reactos/lib/sdk/crt/misc/environ.c
trunk/reactos/lib/sdk/crt/stdio/stat.c
Modified: trunk/reactos/lib/sdk/crt/misc/environ.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/misc/environ.c…
==============================================================================
--- trunk/reactos/lib/sdk/crt/misc/environ.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/misc/environ.c [iso-8859-1] Tue Apr 2 12:53:30 2013
@@ -1,4 +1,4 @@
-/*
+/*
* environ.c
*
* ReactOS MSVCRT.DLL Compatibility Library
@@ -64,11 +64,11 @@
{
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 @@
{
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 @@
*newenvptr = _strdup(*envptr++);
if (*newenvptr == NULL)
{
- for (newenvptr--; newenvptr >= newenv; newenvptr--);
+ for (newenvptr--; newenvptr >= newenv; newenvptr--)
free(*newenvptr);
free(newenv);
return original_environment;
Modified: trunk/reactos/lib/sdk/crt/stdio/stat.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/stdio/stat.c?r…
==============================================================================
--- trunk/reactos/lib/sdk/crt/stdio/stat.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/stdio/stat.c [iso-8859-1] Tue Apr 2 12:53:30 2013
@@ -2,6 +2,7 @@
#include <tchar.h>
#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)
{