nsCAutoString localSchema; localSchema.Assign(schema);
wallet_GetPrefills(  nsIDOMNode* elementNode,  nsIDOMHTMLInputElement*& inputElement,    nsIDOMHTMLSelectElement*& selectElement,  nsACString& schema,  nsString& value,  PRInt32& selectIndex,  PRInt32& index){  nsresult result;  nsCAutoString localSchema; localSchema.Assign(schema);  /* get prefills for input element */  result = elementNode->QueryInterface(NS_GET_IID(nsIDOMHTMLInputElement), (void**)&inputElement);  if ((NS_SUCCEEDED(result)) && (nsnull != inputElement)) {    nsAutoString type;    result = inputElement->GetType(type);    if ((NS_SUCCEEDED(result)) && ((type.IsEmpty()) || (Compare(type, NS_LITERAL_STRING("text"), nsCaseInsensitiveStringComparator()) == 0))) {      nsAutoString field;      result = inputElement->GetName(field);      if (NS_SUCCEEDED(result)) {        nsVoidArray* itemList;        /* try to get schema name from vcard attribute if it exists */        if (localSchema.IsEmpty()) {          nsCOMPtr<nsIDOMElement> element = do_QueryInterface(elementNode);          if (element) {            nsAutoString vcard; vcard.Assign(NS_LITERAL_STRING("VCARD_NAME"));            nsAutoString vcardValueUCS2;            result = element->GetAttribute(vcard, vcardValueUCS2);            if (NS_OK == result) {              nsVoidArray* dummy;              wallet_ReadFromList(NS_ConvertUCS2toUTF8(vcardValueUCS2), localSchema, dummy,                                  wallet_VcardToSchema_list, PR_FALSE);            }          }        }        /* try to get schema name from displayable text if possible */        if (localSchema.IsEmpty()) {          wallet_GetSchemaFromDisplayableText(inputElement, localSchema, PR_FALSE);        }#ifdef IgnoreFieldNames// use displayable text instead of field namesif (!localSchema.IsEmpty()) {#endif        /*         * if schema name was obtained then get value from schema name,         * otherwise get value from field name by using mapping tables to get schema name         */        if (NS_SUCCEEDED(FieldToValue(field, localSchema, value, itemList, index))) {          if (value.IsEmpty() && nsnull != itemList) {            /* pick first of a set of synonymous values */            const char* encryptedValue = ((wallet_Sublist *)itemList->ElementAt(0))->item;            char* valueCString = nsnull;            if (NS_FAILED(DecryptString(encryptedValue, valueCString))) {              NS_RELEASE(inputElement);              return NS_ERROR_FAILURE;            }            value = NS_ConvertUTF8toUCS2(valueCString);          }          selectElement = nsnull;          selectIndex = -1;          schema = localSchema;          return NS_OK;        }      }    }    NS_RELEASE(inputElement);    return NS_ERROR_FAILURE;  }  /* get prefills for dropdown list */  result = elementNode->QueryInterface(NS_GET_IID(nsIDOMHTMLSelectElement), (void**)&selectElement);  if ((NS_SUCCEEDED(result)) && (nsnull != selectElement)) {    nsAutoString field;    result = selectElement->GetName(field);    if (NS_SUCCEEDED(result)) {      /* try to get schema name from displayable text if possible */      if (localSchema.IsEmpty()) {        wallet_GetSchemaFromDisplayableText(selectElement, localSchema, PR_FALSE);      }#ifdef IgnoreFieldNames// use displayable text instead of field namesif (!localSchema.IsEmpty()) {#endif      nsVoidArray* itemList;      if (NS_SUCCEEDED(FieldToValue(field, localSchema, value, itemList, index))) {        if (!value.IsEmpty()) {          /* no synonym list, just one value to try */          result = wallet_GetSelectIndex(selectElement, value, selectIndex);          if (NS_SUCCEEDED(result)) {            /* value matched one of the values in the drop-down list */            inputElement = nsnull;            schema = localSchema;            return NS_OK;          }        } else {          /* synonym list exists, try each value */          for (PRInt32 i=0; i<LIST_COUNT(itemList); i++) {            value = NS_ConvertUTF8toUCS2(((wallet_Sublist *)itemList->ElementAt(i))->item);            result = wallet_GetSelectIndex(selectElement, value, selectIndex);            if (NS_SUCCEEDED(result)) {              /* value matched one of the values in the drop-down list */              // No Release() here?              inputElement = nsnull;              schema = localSchema;              return NS_OK;            }          }        }      }    }    NS_RELEASE(selectElement);  }  return NS_ERROR_FAILURE;}