< Previous by Date Date Index Next by Date >
  Thread Index Next in Thread >

[reSIProcate] Maybe a bug ? SipMessage::remove() is crashed in DumFeature::process() function


Hi all, I have write a class which derived from DumFeature, and implemented the process function:
 
 
DumFeature::ProcessingResult MyFeature::process(Message* msg)
{
 SipMessage* sipMsg = (SipMessage*)msg;
 if (sipMsg)
 {
  const resip::Data headerName("User-Agent");
  resip::Data headerValue("test);
  resip::HeaderBase * headerBase = HeaderBase::getInstance(resip::Headers::getType(headerName.c_str(),headerName.size()));
  if (headerBase)
  {
   if (sipMsg->exists(*headerBase) == true)
   {
    sipMsg->remove(*headerBase);
   }

   HeaderFieldValueList * hfvs = new HeaderFieldValueList();
   hfvs->push_back(new HeaderFieldValue(headerValue.data(), headerValue.size()));
   sipMsg->setRawHeader(hfvs, Headers::getType(headerName.data(), headerName.size()));
  }
 }
 postCommand(auto_ptr<Message>(sipMsg));
 return DumFeature::FeatureDone;
}
 
My application is crashed on sipMsg->remove(*headerBase); I have debug this function:
 
void
SipMessage::remove(const HeaderBase& headerType)
{
   delete mHeaders[headerType.getTypeNum()];   ------------------------->when runing to this line, it will be crashed.
   mHeaders[headerType.getTypeNum()] = 0;
};
 
 
Above code I have using with MessageDecorator::decorateMessage function, it's working fine.
 
And I try to use SipMessage* sipMsg = dynamic_cast<SipMessage*>(msg); to instead SipMessage* sipMsg = (SipMessage*)msg;
but it's failed, the dynamic_cast result it 0.
 
Thanks