mirror of
https://github.com/reactos/reactos.git
synced 2025-07-06 15:51:23 +00:00
[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 svn path=/trunk/; revision=58642
This commit is contained in:
parent
a08dba228c
commit
8e08d249db
2 changed files with 8 additions and 6 deletions
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* environ.c
|
* environ.c
|
||||||
*
|
*
|
||||||
* ReactOS MSVCRT.DLL Compatibility Library
|
* ReactOS MSVCRT.DLL Compatibility Library
|
||||||
|
@ -64,11 +64,11 @@ int BlockEnvToEnvironA(void)
|
||||||
{
|
{
|
||||||
if ((*envptr = malloc(len)) == NULL)
|
if ((*envptr = malloc(len)) == NULL)
|
||||||
{
|
{
|
||||||
for (envptr--; envptr >= _environ; envptr--);
|
for (envptr--; envptr >= _environ; envptr--)
|
||||||
free(*envptr);
|
free(*envptr);
|
||||||
FreeEnvironmentStringsA(environment_strings);
|
FreeEnvironmentStringsA(environment_strings);
|
||||||
free(_environ);
|
free(_environ);
|
||||||
__initenv = _environ = NULL;
|
__initenv = _environ = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
memcpy(*envptr++, ptr, len);
|
memcpy(*envptr++, ptr, len);
|
||||||
|
@ -116,11 +116,11 @@ int BlockEnvToEnvironW(void)
|
||||||
{
|
{
|
||||||
if ((*envptr = malloc(len * sizeof(wchar_t))) == NULL)
|
if ((*envptr = malloc(len * sizeof(wchar_t))) == NULL)
|
||||||
{
|
{
|
||||||
for (envptr--; envptr >= _wenviron; envptr--);
|
for (envptr--; envptr >= _wenviron; envptr--)
|
||||||
free(*envptr);
|
free(*envptr);
|
||||||
FreeEnvironmentStringsW(environment_strings);
|
FreeEnvironmentStringsW(environment_strings);
|
||||||
free(_wenviron);
|
free(_wenviron);
|
||||||
__winitenv = _wenviron = NULL;
|
__winitenv = _wenviron = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
memcpy(*envptr++, ptr, len * sizeof(wchar_t));
|
memcpy(*envptr++, ptr, len * sizeof(wchar_t));
|
||||||
|
@ -168,7 +168,7 @@ char **DuplicateEnvironment(char **original_environment, int wide)
|
||||||
*newenvptr = _strdup(*envptr++);
|
*newenvptr = _strdup(*envptr++);
|
||||||
if (*newenvptr == NULL)
|
if (*newenvptr == NULL)
|
||||||
{
|
{
|
||||||
for (newenvptr--; newenvptr >= newenv; newenvptr--);
|
for (newenvptr--; newenvptr >= newenv; newenvptr--)
|
||||||
free(*newenvptr);
|
free(*newenvptr);
|
||||||
free(newenv);
|
free(newenv);
|
||||||
return original_environment;
|
return original_environment;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
|
|
||||||
#define stat64_to_stat(buf64, buf) \
|
#define stat64_to_stat(buf64, buf) \
|
||||||
|
do { \
|
||||||
buf->st_dev = (buf64)->st_dev; \
|
buf->st_dev = (buf64)->st_dev; \
|
||||||
buf->st_ino = (buf64)->st_ino; \
|
buf->st_ino = (buf64)->st_ino; \
|
||||||
buf->st_mode = (buf64)->st_mode; \
|
buf->st_mode = (buf64)->st_mode; \
|
||||||
|
@ -13,6 +14,7 @@
|
||||||
buf->st_atime = (time_t)(buf64)->st_atime; \
|
buf->st_atime = (time_t)(buf64)->st_atime; \
|
||||||
buf->st_mtime = (time_t)(buf64)->st_mtime; \
|
buf->st_mtime = (time_t)(buf64)->st_mtime; \
|
||||||
buf->st_ctime = (time_t)(buf64)->st_ctime; \
|
buf->st_ctime = (time_t)(buf64)->st_ctime; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
int CDECL _tstat(const _TCHAR* path, struct _stat * buf)
|
int CDECL _tstat(const _TCHAR* path, struct _stat * buf)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue