@@ -464,29 +464,30 @@ static HRESULT GetFwRuleInterfaces(
464464 }
465465 }
466466
467- ExitOnNull (iInterfacesCount, hr, S_OK, " All interfaces are empty values" );
468-
469- vInterfaces.vt = VT_ARRAY | VT_VARIANT;
470- // this will be cleaned up by ReleaseVariant call of the calling function
471- vInterfaces.parray = SafeArrayCreateVector (VT_VARIANT, 0 , iInterfacesCount);
472-
473- for (LPCWSTR pwzElement = bstrInterfaces; pwzElement < (bstrInterfaces + iLength); ++pwzElement)
467+ if (iInterfacesCount > 0 )
474468 {
475- if (*pwzElement)
469+ vInterfaces.vt = VT_ARRAY | VT_VARIANT;
470+ // this will be cleaned up by ReleaseVariant call of the calling function
471+ vInterfaces.parray = SafeArrayCreateVector (VT_VARIANT, 0 , iInterfacesCount);
472+
473+ for (LPCWSTR pwzElement = bstrInterfaces; pwzElement < (bstrInterfaces + iLength); ++pwzElement)
476474 {
477- VARIANT vElement;
478- ::VariantInit (&vElement);
475+ if (*pwzElement)
476+ {
477+ VARIANT vElement;
478+ ::VariantInit (&vElement);
479479
480- vElement.vt = VT_BSTR;
481- // this will be cleaned up by ReleaseVariant call of the calling function
482- vElement.bstrVal = ::SysAllocString (pwzElement);
483- ExitOnNull (vElement.bstrVal , hr, E_OUTOFMEMORY, " failed SysAllocString for interface element" );
480+ vElement.vt = VT_BSTR;
481+ // this will be cleaned up by ReleaseVariant call of the calling function
482+ vElement.bstrVal = ::SysAllocString (pwzElement);
483+ ExitOnNull (vElement.bstrVal , hr, E_OUTOFMEMORY, " failed SysAllocString for interface element" );
484484
485- hr = SafeArrayPutElement (vInterfaces.parray , &iIndex, &vElement);
486- ExitOnFailure (hr, " failed to put interface '%ls' into safe array" , pwzElement);
485+ hr = SafeArrayPutElement (vInterfaces.parray , &iIndex, &vElement);
486+ ExitOnFailure (hr, " failed to put interface '%ls' into safe array" , pwzElement);
487487
488- pwzElement += ::SysStringLen (vElement.bstrVal );
489- iIndex++;
488+ pwzElement += ::SysStringLen (vElement.bstrVal );
489+ iIndex++;
490+ }
490491 }
491492 }
492493
0 commit comments