mParamNames[mNumParams] = name.ToNewUTF8String(); mParamVals[mNumParams]  = val.ToNewUTF8String();
mParamNames[mNumParams] = ToNewUTF8String(name); mParamVals[mNumParams]  = ToNewUTF8String(val);
NS_IMETHODIMP nsPluginInstanceOwner::GetParameters(PRUint16& n, const char*const*& names, const char*const*& values){  nsresult rv = NS_ERROR_FAILURE;  if ((nsnull == mParamNames) && (nsnull != mOwner))  {    nsIContent  *cont;    mOwner->GetContent(&cont);    if (nsnull != cont)    {      PRBool  haskids = PR_FALSE;      cont->CanContainChildren(haskids);      if (PR_TRUE == haskids)      {        PRInt32 numkids, idx, numparams = 0;        cont->ChildCount(numkids);        //first pass, count number of param tags...        for (idx = 0; idx < numkids; idx++)        {          nsIContent  *kid;          cont->ChildAt(idx, kid);          if (nsnull != kid)          {            nsIAtom     *atom;            kid->GetTag(atom);            if (nsnull != atom)            {              if (atom == nsHTMLAtoms::param)                numparams++;              NS_RELEASE(atom);            }            NS_RELEASE(kid);          }        }        if (numparams > 0)        {          //now we need to create arrays          //representing the parameter name/value pairs...          mParamNames = (char **)PR_Calloc(sizeof(char *) * numparams, 1);          mParamVals = (char **)PR_Calloc(sizeof(char *) * numparams, 1);          if ((nsnull != mParamNames) && (nsnull != mParamVals))          {            for (idx = 0; idx < numkids; idx++)            {              nsIContent  *kid;              cont->ChildAt(idx, kid);              if (nsnull != kid)              {                nsIAtom     *atom;                kid->GetTag(atom);                if (nsnull != atom)                {                  if (atom == nsHTMLAtoms::param)                  {                    nsAutoString  val, name;                    //add param to list...                    if ((NS_CONTENT_ATTR_HAS_VALUE == kid->GetAttr(kNameSpaceID_HTML, nsHTMLAtoms::name, name)) &&                        (NS_CONTENT_ATTR_HAS_VALUE == kid->GetAttr(kNameSpaceID_HTML, nsHTMLAtoms::value, val)))                    {/*       Changing to ToNewUTF8String addressing 17169, 39789                      mParamNames[mNumParams] = (char *)PR_Malloc(name.Length() + 1);                      mParamVals[mNumParams] = (char *)PR_Malloc(val.Length() + 1);                      if ((nsnull != mParamNames[mNumParams]) &&                          (nsnull != mParamVals[mNumParams]))                      {                        name.ToCString(mParamNames[mNumParams], name.Length() + 1);                        val.ToCString(mParamVals[mNumParams], val.Length() + 1);                        mNumParams++;                      }                      else                      {                        if (nsnull != mParamNames[mNumParams])                        {                          PR_Free(mParamNames[mNumParams]);                          mParamNames[mNumParams] = nsnull;                        }                        if (nsnull != mParamVals[mNumParams])                        {                          PR_Free(mParamVals[mNumParams]);                          mParamVals[mNumParams] = nsnull;                        }                      }*/                      /* According to the HTML 4.01 spec, at                       * http://www.w3.org/TR/html4/types.html#type-cdata                       * ''User agents may ignore leading and trailing                       * white space in CDATA attribute values (e.g., "                       * myval " may be interpreted as "myval"). Authors                       * should not declare attribute values with                       * leading or trailing white space.''                       */                      name.CompressWhitespace();                      val.CompressWhitespace();                      mParamNames[mNumParams] = name.ToNewUTF8String();                      mParamVals[mNumParams]  = val.ToNewUTF8String();                      mNumParams++;                    }                  }                  NS_RELEASE(atom);                }              }              NS_RELEASE(kid);            }          }        }      }      rv = NS_OK;      NS_RELEASE(cont);    }  }  n = mNumParams;  names = (const char **)mParamNames;  values = (const char **)mParamVals;  return rv;}