diff --git a/apps/app_sendtext.c b/apps/app_sendtext.c
index 99dbeea7e6118593c795e3ebed9f0649cb11c4a7..2624fe505b4e05c72bab48deec5af09b147d6e33 100644
--- a/apps/app_sendtext.c
+++ b/apps/app_sendtext.c
@@ -98,10 +98,10 @@ static int sendtext_exec(struct ast_channel *chan, const char *data)
 		return 0;
 	}
 	status = "FAILURE";
-	ast_channel_unlock(chan);
 	if (!ast_sendtext(chan, ast_str_buffer(str))) {
 		status = "SUCCESS";
 	}
+	ast_channel_unlock(chan);
 	pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status);
 	return 0;
 }
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 760c2ce818eabe83e94c33581c6a784998fc7347..d5ee01345e8dda973597e86281ff8debcf049c90 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -15475,7 +15475,7 @@ static void receive_message(struct sip_pvt *p, struct sip_request *req)
 		f.subclass.integer = 0;
 		f.offset = 0;
 		f.data.ptr = buf;
-		f.datalen = strlen(buf);
+		f.datalen = strlen(buf) + 1;
 		ast_queue_frame(p->owner, &f);
 		transmit_response(p, "202 Accepted", req); /* We respond 202 accepted, since we relay the message */
 		return;
diff --git a/main/channel.c b/main/channel.c
index 06ee8bb85f5731e58428b0e43af2496fc4cbd7aa..0cabf2d7e073cc6500505646f73687d2712cc1ba 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -4466,13 +4466,18 @@ char *ast_recvtext(struct ast_channel *chan, int timeout)
 int ast_sendtext(struct ast_channel *chan, const char *text)
 {
 	int res = 0;
+
+	ast_channel_lock(chan);
 	/* Stop if we're a zombie or need a soft hangup */
-	if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan))
+	if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) {
+		ast_channel_unlock(chan);
 		return -1;
+	}
 	CHECK_BLOCKING(chan);
 	if (chan->tech->send_text)
 		res = chan->tech->send_text(chan, text);
 	ast_clear_flag(chan, AST_FLAG_BLOCKING);
+	ast_channel_unlock(chan);
 	return res;
 }
 
diff --git a/main/manager.c b/main/manager.c
index 896c7b84cdad58a9e2e8138ab1745c7d21e9227a..40804bf31187d924cefda6622df50d8a865e8eea 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -3245,12 +3245,10 @@ static int action_sendtext(struct mansession *s, const struct message *m)
 		return 0;
 	}
 
-	ast_channel_lock(c);
 	res = ast_sendtext(c, textmsg);
-	ast_channel_unlock(c);
 	c = ast_channel_unref(c);
 
-	if (res > 0) {
+	if (res >= 0) {
 		astman_send_ack(s, m, "Success");
 	} else {
 		astman_send_error(s, m, "Failure");