1
mirror of https://code.videolan.org/videolan/vlc synced 2024-10-07 03:56:28 +02:00

vlccontrol.cpp: fixed bounds issue when allocating memory and iterating through a SafeArray, thanks to Walter Zheng for reporting this problem

This commit is contained in:
Damien Fouilleul 2006-02-21 16:38:23 +00:00
parent 008e13fc27
commit 5ce8549184

View File

@ -632,12 +632,12 @@ static HRESULT createTargetOptions(int codePage, VARIANT *options, char ***cOpti
// marshall options into an array of C strings
if( VT_VARIANT == vType )
{
*cOptions = (char **)CoTaskMemAlloc(sizeof(char *)*(uBound-lBound));
*cOptions = (char **)CoTaskMemAlloc(sizeof(char *)*(uBound-lBound+1));
if( NULL == *cOptions )
return E_OUTOFMEMORY;
ZeroMemory(*cOptions, sizeof(char *)*(uBound-lBound));
for(pos=lBound; SUCCEEDED(hr) && (pos<=uBound); ++pos )
ZeroMemory(*cOptions, sizeof(char *)*(uBound-lBound+1));
for(pos=lBound; (pos<=uBound) && SUCCEEDED(hr); ++pos )
{
VARIANT option;
hr = SafeArrayGetElement(array, &pos, &option);
@ -659,12 +659,12 @@ static HRESULT createTargetOptions(int codePage, VARIANT *options, char ***cOpti
}
else if( VT_BSTR == vType )
{
*cOptions = (char **)CoTaskMemAlloc(sizeof(char *)*(uBound-lBound));
*cOptions = (char **)CoTaskMemAlloc(sizeof(char *)*(uBound-lBound+1));
if( NULL == *cOptions )
return E_OUTOFMEMORY;
ZeroMemory(*cOptions, sizeof(char *)*(uBound-lBound));
for(pos=lBound; (pos<uBound) && SUCCEEDED(hr); ++pos )
ZeroMemory(*cOptions, sizeof(char *)*(uBound-lBound+1));
for(pos=lBound; (pos<=uBound) && SUCCEEDED(hr); ++pos )
{
BSTR option;
hr = SafeArrayGetElement(array, &pos, &option);