Subject: IQGrabber.OnIQ() crashes if callback is null
If IQGrabber.SendIq(IQ iq, IqCB cb, object cbArg) is invoked with cb = null, a null reference for the callback is stored for the IQ's ID in the m_grabbing hashtable. This leads to a NullReferenceException at line 76 in IQGrabber.OnIq(object sender, agsXMPP.Xml.Dom.Node e) when the answer for the IQ is received.
IQGrabber.SendIq(IQ iq, IqCB cb, object cbArg) should only register a callback in the hashtable if cb != null. Proposed patch:
IQGrabber.SendIq(IQ iq, IqCB cb, object cbArg) should only register a callback in the hashtable if cb != null. Proposed patch:
Index: IqGrabber.cs
===================================================================
--- IqGrabber.cs (revision 76)
+++ IqGrabber.cs (working copy)
@@ -80,12 +80,15 @@
/// Send an IQ Request and store the object with callback in the Hashtable
/// </summary>
public void SendIq(IQ iq, IqCB cb, object cbArg)
- {
- TrackerData td = new TrackerData();
- td.cb = cb;
- td.data = cbArg;
+ {
+ if (cb != null)
+ {
+ TrackerData td = new TrackerData();
+ td.cb = cb;
+ td.data = cbArg;
- m_grabbing[iq.Id] = td;
+ m_grabbing[iq.Id] = td;
+ }
m_connection.Send(iq);
}
===================================================================
--- IqGrabber.cs (revision 76)
+++ IqGrabber.cs (working copy)
@@ -80,12 +80,15 @@
/// Send an IQ Request and store the object with callback in the Hashtable
/// </summary>
public void SendIq(IQ iq, IqCB cb, object cbArg)
- {
- TrackerData td = new TrackerData();
- td.cb = cb;
- td.data = cbArg;
+ {
+ if (cb != null)
+ {
+ TrackerData td = new TrackerData();
+ td.cb = cb;
+ td.data = cbArg;
- m_grabbing[iq.Id] = td;
+ m_grabbing[iq.Id] = td;
+ }
m_connection.Send(iq);
}