bug 439266, BuildSearchElements() leaks array and all its elements if rv is not NS_OK. r=Standard8

This commit is contained in:
hwaara%gmail.com 2008-06-26 14:16:38 +00:00
Родитель 8f9a1c91b0
Коммит b445ff4ce8
1 изменённых файлов: 11 добавлений и 5 удалений

Просмотреть файл

@ -394,17 +394,21 @@ BuildSearchElements(nsIAbBooleanExpression *aExpression,
condition = do_QueryElementAt(expressions, i);
if (condition) {
rv = MapConditionString(condition, operation == nsIAbBooleanOperationTypes::NOT, aCanHandle, &element);
NS_ENSURE_SUCCESS(rv, rv);
if (NS_FAILED(rv))
break;
}
else {
subExpression = do_QueryElementAt(expressions, i);
if (subExpression) {
rv = BuildSearchElements(subExpression, aCanHandle, &element);
NS_ENSURE_SUCCESS(rv, rv);
if (NS_FAILED(rv))
break;
}
}
if (!aCanHandle) {
// remember to free the array when returning early
[array release];
return NS_OK;
}
@ -417,12 +421,14 @@ BuildSearchElements(nsIAbBooleanExpression *aExpression,
}
if (array) {
ABSearchConjunction conjunction = operation == nsIAbBooleanOperationTypes::AND ? kABSearchAnd : kABSearchOr;
*aResult = [ABSearchElement searchElementForConjunction:conjunction children:array];
if (NS_SUCCEEDED(rv)) {
ABSearchConjunction conjunction = operation == nsIAbBooleanOperationTypes::AND ? kABSearchAnd : kABSearchOr;
*aResult = [ABSearchElement searchElementForConjunction:conjunction children:array];
}
[array release];
}
return NS_OK;
return rv;
}
static PRBool