diff --git a/main/pbx.c b/main/pbx.c
index d3121234f633b10a1e3c01322db174ac97b6d3ea..5ab13babc459ea058b0659e0580471743020acca 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -3155,8 +3155,10 @@ int ast_spawn_extension(struct ast_channel *c, const char *context, const char *
 /*! helper function to set extension and priority */
 static void set_ext_pri(struct ast_channel *c, const char *exten, int pri)
 {
+	ast_channel_lock(c);
 	ast_copy_string(c->exten, exten, sizeof(c->exten));
 	c->priority = pri;
+	ast_channel_unlock(c);
 }
 
 /*!