Commit 5ce85491 authored by Damien Fouilleul's avatar Damien Fouilleul

vlccontrol.cpp: fixed bounds issue when allocating memory and iterating...

vlccontrol.cpp: fixed bounds issue when allocating memory and iterating through a SafeArray, thanks to Walter Zheng for reporting this problem
parent 008e13fc
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment