mirror of
https://github.com/reactos/reactos.git
synced 2025-06-10 20:34:59 +00:00
[CRT]
Properly copy va_list (ie, do it in a portable and corrrect way) and make sure it doesn't leak svn path=/trunk/; revision=67772
This commit is contained in:
parent
2d5809b784
commit
a185668536
1 changed files with 6 additions and 1 deletions
|
@ -152,13 +152,14 @@ argvtosT(const _TCHAR* const* argv, _TCHAR delim)
|
||||||
static _TCHAR*
|
static _TCHAR*
|
||||||
valisttosT(const _TCHAR* arg0, va_list alist, _TCHAR delim)
|
valisttosT(const _TCHAR* arg0, va_list alist, _TCHAR delim)
|
||||||
{
|
{
|
||||||
va_list alist2 = alist;
|
va_list alist2;
|
||||||
_TCHAR *ptr, *str;
|
_TCHAR *ptr, *str;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
if (arg0 == NULL)
|
if (arg0 == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
va_copy(alist2, alist);
|
||||||
ptr = (_TCHAR*)arg0;
|
ptr = (_TCHAR*)arg0;
|
||||||
len = 0;
|
len = 0;
|
||||||
do
|
do
|
||||||
|
@ -170,7 +171,10 @@ valisttosT(const _TCHAR* arg0, va_list alist, _TCHAR delim)
|
||||||
|
|
||||||
str = (_TCHAR*) malloc((len + 1) * sizeof(_TCHAR));
|
str = (_TCHAR*) malloc((len + 1) * sizeof(_TCHAR));
|
||||||
if (str == NULL)
|
if (str == NULL)
|
||||||
|
{
|
||||||
|
va_end(alist2);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
ptr = str;
|
ptr = str;
|
||||||
do
|
do
|
||||||
|
@ -184,6 +188,7 @@ valisttosT(const _TCHAR* arg0, va_list alist, _TCHAR delim)
|
||||||
while(arg0 != NULL);
|
while(arg0 != NULL);
|
||||||
*ptr = 0;
|
*ptr = 0;
|
||||||
|
|
||||||
|
va_end(alist2);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue