Skip to contentSkip to conversation

stk: reorder: Don't access freed memory in Send SMS

PATCH In review Andrzej Zaborowski 2 participants 2 messages Aug 20, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 stk: reorder: Don't access freed memory in Send SMS

Responding to the stk->pending_cmd frees it, we need to read it before that.

---
 src/stk.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
src/stk.c +4 -4
index ce71075..f391396 100644
@@ -695,6 +695,10 @@ static void send_sms_submit_cb(gboolean ok, void *data)
 		return;
 	}
 
+	if (stk->pending_cmd->send_sms.alpha_id &&
+			stk->pending_cmd->send_sms.alpha_id[0])
+		stk_alpha_id_unset(stk);
+
 	memset(&rsp, 0, sizeof(rsp));
 
 	if (ok == FALSE)
@@ -702,10 +706,6 @@ static void send_sms_submit_cb(gboolean ok, void *data)
 
 	if (stk_respond(stk, &rsp, stk_command_cb))
 		stk_command_cb(&failure, stk);
-
-	if (stk->pending_cmd->send_sms.alpha_id &&
-			stk->pending_cmd->send_sms.alpha_id[0])
-		stk_alpha_id_unset(stk);
 }
 
 static gboolean handle_command_send_sms(const struct stk_command *cmd,
Signature · 1 line
1.7.1.86.g0e460.dirty
#1 lore raw

Hi Andrew,

Quoted 3 lines · Andrzej Zaborowski

Responding to the stk->pending_cmd frees it, we need to read it before that.
---

Patch has been applied, thanks.

Regards,
-Denis