diff --git a/src/switch_core_io.c b/src/switch_core_io.c
index 29e47a2dd9..1cd902473e 100644
--- a/src/switch_core_io.c
+++ b/src/switch_core_io.c
@@ -892,12 +892,16 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
 				switch_assert(enc_frame->data != NULL);
 				session->read_codec->cur_frame = enc_frame;
 				enc_frame->codec->cur_frame = enc_frame;
+				switch_assert(enc_frame->datalen <= SWITCH_RECOMMENDED_BUFFER_SIZE);
+				switch_assert(session->enc_read_frame.datalen <= SWITCH_RECOMMENDED_BUFFER_SIZE);
 				status = switch_core_codec_encode(session->read_codec,
 												  enc_frame->codec,
 												  enc_frame->data,
 												  enc_frame->datalen,
 												  session->read_impl.actual_samples_per_second,
 												  session->enc_read_frame.data, &session->enc_read_frame.datalen, &session->enc_read_frame.rate, &flag);
+				switch_assert(session->enc_read_frame.datalen <= SWITCH_RECOMMENDED_BUFFER_SIZE);
+
 				session->read_codec->cur_frame = NULL;
 				enc_frame->codec->cur_frame = NULL;
 				switch (status) {
@@ -1475,6 +1479,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
 			session->enc_write_frame.datalen = session->enc_write_frame.buflen;
 			session->write_codec->cur_frame = frame;
 			frame->codec->cur_frame = frame;
+			switch_assert(enc_frame->datalen <= SWITCH_RECOMMENDED_BUFFER_SIZE);
+			switch_assert(session->enc_read_frame.datalen <= SWITCH_RECOMMENDED_BUFFER_SIZE);
 			status = switch_core_codec_encode(session->write_codec,
 											  frame->codec,
 											  enc_frame->data,
@@ -1482,6 +1488,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
 											  session->write_impl.actual_samples_per_second,
 											  session->enc_write_frame.data, &session->enc_write_frame.datalen, &session->enc_write_frame.rate, &flag);
 
+			switch_assert(session->enc_read_frame.datalen <= SWITCH_RECOMMENDED_BUFFER_SIZE);
+
 			session->write_codec->cur_frame = NULL;
 			frame->codec->cur_frame = NULL;
 			switch (status) {
@@ -1582,6 +1590,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
 
 				session->write_codec->cur_frame = frame;
 				frame->codec->cur_frame = frame;
+				switch_assert(enc_frame->datalen <= SWITCH_RECOMMENDED_BUFFER_SIZE);
+				switch_assert(session->enc_read_frame.datalen <= SWITCH_RECOMMENDED_BUFFER_SIZE);
 				status = switch_core_codec_encode(session->write_codec,
 												  frame->codec,
 												  enc_frame->data,
@@ -1589,6 +1599,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
 												  rate,
 												  session->enc_write_frame.data, &session->enc_write_frame.datalen, &session->enc_write_frame.rate, &flag);
 
+				switch_assert(session->enc_read_frame.datalen <= SWITCH_RECOMMENDED_BUFFER_SIZE);
+
 				session->write_codec->cur_frame = NULL;
 				frame->codec->cur_frame = NULL;
 				switch (status) {