nsOption* selected = (nsOption*)ChildAt(index); selected->GetNamesValues(aMaxNumValues, aNumValues, aValues, aNames); aNames[0] = *mName; NS_RELEASE(selected); return PR_TRUE;
nsOption* selected = GetNthOption(index); if (selected) { selected->GetNamesValues(aMaxNumValues, aNumValues, aValues, aNames); aNames[0] = *mName; NS_RELEASE(selected); return PR_TRUE; }
nsSelect::GetNamesValues(PRInt32 aMaxNumValues, PRInt32& aNumValues,                         nsString* aValues, nsString* aNames){  if ((aMaxNumValues <= 0) || (nsnull == mName)) {    NS_ASSERTION(0, "invalid max num values");    return PR_FALSE;  }  if (!IsMultiple()) {    NS_ASSERTION(aMaxNumValues > 0, "invalid max num values");    nsIListWidget* list;    nsresult stat = mWidget->QueryInterface(kListWidgetIID, (void **) &list);    NS_ASSERTION((NS_OK == stat), "invalid widget");    PRInt32 index = list->GetSelectedIndex();    if (index >= 0) {      nsOption* selected = (nsOption*)ChildAt(index);      selected->GetNamesValues(aMaxNumValues, aNumValues, aValues, aNames);      aNames[0] = *mName;      NS_RELEASE(selected); // YYY remove this comment if ok      return PR_TRUE;    }    else {      aNumValues = 0;      return PR_FALSE;    }  }  else {    nsIListBox* list;    nsresult stat = mWidget->QueryInterface(kListBoxIID, (void **) &list);    NS_ASSERTION((NS_OK == stat), "invalid widget");    PRInt32 numSelections = list->GetSelectedCount();    NS_ASSERTION(aMaxNumValues >= numSelections, "invalid max num values");    if (numSelections >= 0) {      PRInt32* selections = new PRInt32[numSelections];      list->GetSelectedIndices(selections, numSelections);      PRInt32 numValues;      aNumValues = 0;      for (int i = 0; i < numSelections; i++) {        nsOption* selected = (nsOption*)ChildAt(selections[i]);        selected->GetNamesValues(aMaxNumValues - i, numValues,                                  aValues + i, aNames + i);  // options can only have 1 value        aNames[i] = *mName;        aNumValues += 1;        NS_RELEASE(selected); // YYY remove this comment if ok      }      return PR_TRUE;    }    else {      aNumValues = 0;      return PR_FALSE;    }  }}