From 8618e5577494498e3b7498c1eccdc184f9fc1dc0 Mon Sep 17 00:00:00 2001
From: James Turner <james@flightgear.org>
Date: Tue, 8 Jun 2021 17:46:50 +0100
Subject: [PATCH] FGCom: attempt to avoid crashes seen by Sentry
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This is a wild guess, but shouldn’t do any harm and might give some
data about what is going wrong.
---
 3rdparty/iaxclient/lib/libiax2/src/iax.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/3rdparty/iaxclient/lib/libiax2/src/iax.c b/3rdparty/iaxclient/lib/libiax2/src/iax.c
index e3d5a1991..37b0171cc 100644
--- a/3rdparty/iaxclient/lib/libiax2/src/iax.c
+++ b/3rdparty/iaxclient/lib/libiax2/src/iax.c
@@ -868,7 +868,12 @@ static int iax_xmit_frame(struct iax_frame *f)
 										f->datalen - sizeof(struct ast_iax2_full_hdr));
 	}
 #endif
-	/* Send the frame raw */
+    if (!f->session) {
+        IAXERROR "No session in iax_xmit_frame");
+        return -1;
+    }
+
+    /* Send the frame raw */
 	res = f->session->sendto(netfd, (const char *) f->data, f->datalen,
 			IAX_SOCKOPTS, f->transfer ?
 			(struct sockaddr *)&(f->session->transfer) :