mAttrNames[mNumAttrs] = name.ToNewUTF8String(); mAttrVals[mNumAttrs] = value.ToNewUTF8String();
mAttrNames[mNumAttrs] = ToNewUTF8String(name); mAttrVals[mNumAttrs] = ToNewUTF8String(value);
NS_IMETHODIMP nsPluginInstanceOwner::GetAttributes(PRUint16& n,                                                     const char*const*& names,                                                     const char*const*& values){  nsresult    rv;  nsIContent* iContent;  if ((nsnull == mAttrNames) && (nsnull != mOwner)) {    rv = mOwner->GetContent(&iContent);    if (NS_SUCCEEDED(rv)) {      PRInt32 count;      if (NS_SUCCEEDED(iContent->GetAttrCount(count))) {        PRInt32 index;        mAttrNames = (char **)PR_Calloc(sizeof(char *) * count, 1);        mAttrVals = (char **)PR_Calloc(sizeof(char *) * count, 1);        mNumAttrs = 0;        if ((nsnull != mAttrNames) && (nsnull != mAttrVals)) {          for (index = 0; index < count; index++) {            PRInt32 nameSpaceID;            nsCOMPtr<nsIAtom> atom;            nsCOMPtr<nsIAtom> prefix;            iContent->GetAttrNameAt(index, nameSpaceID,                                    *getter_AddRefs(atom),                                    *getter_AddRefs(prefix));            nsAutoString  value;            if (NS_CONTENT_ATTR_HAS_VALUE ==                  iContent->GetAttr(nameSpaceID, atom, value)) {              nsAutoString  name;              atom->ToString(name);/*       Changing to ToNewUTF8String addressing 17169, 39789              mAttrNames[mNumAttrs] = (char *)PR_Malloc(name.Length() + 1);              mAttrVals[mNumAttrs] = (char *)PR_Malloc(value.Length() + 1);              if ((nsnull != mAttrNames[mNumAttrs]) &&                  (nsnull != mAttrVals[mNumAttrs]))              {                name.ToCString(mAttrNames[mNumAttrs], name.Length() + 1);                value.ToCString(mAttrVals[mNumAttrs], value.Length() + 1);                mNumAttrs++;              }              else              {                if (nsnull != mAttrNames[mNumAttrs])                {                  PR_Free(mAttrNames[mNumAttrs]);                  mAttrNames[mNumAttrs] = nsnull;                }                if (nsnull != mAttrVals[mNumAttrs])                {                  PR_Free(mAttrVals[mNumAttrs]);                  mAttrVals[mNumAttrs] = nsnull;                }              }*/              mAttrNames[mNumAttrs] = name.ToNewUTF8String();              mAttrVals[mNumAttrs] = value.ToNewUTF8String();              mNumAttrs++;            }          }        }        else {          rv = NS_ERROR_OUT_OF_MEMORY;          if (nsnull != mAttrVals) {            PR_Free(mAttrVals);            mAttrVals = nsnull;          }          if (nsnull != mAttrNames) {            PR_Free(mAttrNames);            mAttrNames = nsnull;          }        }      }      NS_RELEASE(iContent);    }  }  else {    rv = NS_OK;  }  n = mNumAttrs;  names = (const char **)mAttrNames;  values = (const char **)mAttrVals;  return rv;}