[reSIProcate] Maybe a bug ? SipMessage::remove() is crashed in DumFeature::process() function
Karlsson
boost.regex at gmail.com
Sat Oct 4 08:08:21 CDT 2008
If delete sipMsg->remove, the application still get crash, same line.
On Sat, Oct 4, 2008 at 8:57 PM, Justin Matthews <jmatthewsr at gmail.com>wrote:
> Not sure why the dynamic_cast is always returning 0. Are you running the
> cast in a project that does not have RTTI enabled in the project/compiler
> settings?
>
>
>
> sipMsg->remove: look at the implementation for SipMessage::setRawHeader.
>
>
>
>
>
> -justin
>
>
>
> *From:* Karlsson [mailto:boost.regex at gmail.com]
> *Sent:* Saturday, October 04, 2008 8:04 AM
> *To:* Justin Matthews
> *Cc:* resiprocate-devel
> *Subject:* Re: [reSIProcate] Maybe a bug ? SipMessage::remove() is crashed
> in DumFeature::process() function
>
>
>
> I have DEBUG it, the SipMessage* sipMsg =
> dynamic_cast<SipMessage*>(msg); always return 0, it's never succeed.
>
>
>
>
>
> And I have wrote these code:
>
>
>
> SipMessage* sipMsg = (SipMessage*)msg;
>
> Data Text = Data::From(*sipMsg);
>
> MessageBox(NULL, Text.c_str(), "message", MB_ICONINFORMATION);
>
>
>
> The message box show it's SIP message correctly, so I don't know why the
> dynamic_cast return 0.
>
>
>
>
>
>
>
> I have read your code, I saw you have delete the
> sipMsg->remove(*headerBase); why ?
>
>
>
> Thanks
>
>
>
>
>
> On Sat, Oct 4, 2008 at 7:42 PM, Justin Matthews <jmatthewsr at gmail.com>
> wrote:
>
> You need to dynamic cast the Message pointer and if it's 0 then it's not a
> SipMessage and you should ignore it.
>
>
>
> Also, I think you still need to make a copy of the HeaderFieldValue to
> allocate a buffer that is owned by the underlying HeaderFieldValue.
>
>
>
> Untested code:
>
>
>
>
>
> DumFeature::ProcessingResult MyFeature::process(Message* msg)
> {
>
> SipMessage* sipMsg = dynamic_cast<SipMessage*>(msg);
>
> if (sipMsg)
>
> {
>
> const resip::Data headerName("User-Agent");
>
> resip::Data headerValue("test");
>
>
>
> Headers::Type headerType = Headers::getType(headerName.data(),
> headerName.size());
>
>
>
> if (headerType != Headers::UNKNOWN)
>
> {
>
> HeaderFieldValueList * hfvs = new HeaderFieldValueList();
>
> hfvs->push_back(new
> HeaderFieldValue(HeaderFieldValue(headerValue.data(), headerValue.size())));
>
> sipMsg->setRawHeader(hfvs, headerType);
>
> }
>
> }
>
> postCommand(auto_ptr<Message>(sipMsg));
>
> return DumFeature::FeatureDone;
>
> }
>
>
>
> *From:* resiprocate-devel-bounces at resiprocate.org [mailto:
> resiprocate-devel-bounces at resiprocate.org] *On Behalf Of *Karlsson
> *Sent:* Friday, October 03, 2008 11:42 PM
> *To:* resiprocate-devel
> *Subject:* [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
>
>
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.resiprocate.org/pipermail/resiprocate-devel/attachments/20081004/d2db499f/attachment.htm>
More information about the resiprocate-devel
mailing list