mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 08:55:19 +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*
|
||||
valisttosT(const _TCHAR* arg0, va_list alist, _TCHAR delim)
|
||||
{
|
||||
va_list alist2 = alist;
|
||||
va_list alist2;
|
||||
_TCHAR *ptr, *str;
|
||||
size_t len;
|
||||
|
||||
if (arg0 == NULL)
|
||||
return NULL;
|
||||
|
||||
va_copy(alist2, alist);
|
||||
ptr = (_TCHAR*)arg0;
|
||||
len = 0;
|
||||
do
|
||||
|
@ -170,7 +171,10 @@ valisttosT(const _TCHAR* arg0, va_list alist, _TCHAR delim)
|
|||
|
||||
str = (_TCHAR*) malloc((len + 1) * sizeof(_TCHAR));
|
||||
if (str == NULL)
|
||||
{
|
||||
va_end(alist2);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ptr = str;
|
||||
do
|
||||
|
@ -184,6 +188,7 @@ valisttosT(const _TCHAR* arg0, va_list alist, _TCHAR delim)
|
|||
while(arg0 != NULL);
|
||||
*ptr = 0;
|
||||
|
||||
va_end(alist2);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue