summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Kenzior <denis.kenzior@intel.com>2009-09-07 23:20:29 -0500
committerDenis Kenzior <denkenz@gmail.com>2009-09-07 23:21:50 -0500
commit2ee7f4a6f8333528f6645d4bcfcc08f58879b2b9 (patch)
tree4f2c267805fbb75463c64906a37f8a9d8515ceec
parent74d0493230416dbf15e5dfe41de8d53e166ac0c7 (diff)
downloadofono-2ee7f4a6f8333528f6645d4bcfcc08f58879b2b9.tar.bz2
Fix g_at_chat_unref from command callback
The resources were being used after being freed in this case
-rw-r--r--gatchat/gatchat.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/gatchat/gatchat.c b/gatchat/gatchat.c
index e6fd5743..186c62ef 100644
--- a/gatchat/gatchat.c
+++ b/gatchat/gatchat.c
@@ -324,34 +324,36 @@ static void g_at_chat_finish_command(GAtChat *p, gboolean ok,
char *final)
{
struct at_command *cmd = g_queue_pop_head(p->command_queue);
+ GSList *response_lines;
/* Cannot happen, but lets be paranoid */
if (!cmd)
return;
+ p->cmd_bytes_written = 0;
+
+ if (g_queue_peek_head(p->command_queue))
+ g_at_chat_wakeup_writer(p);
+
+ response_lines = p->response_lines;
+ p->response_lines = NULL;
+
if (cmd->callback) {
GAtResult result;
- p->response_lines = g_slist_reverse(p->response_lines);
+ response_lines = g_slist_reverse(response_lines);
result.final_or_pdu = final;
- result.lines = p->response_lines;
+ result.lines = response_lines;
cmd->callback(ok, &result, cmd->user_data);
}
- g_slist_foreach(p->response_lines, (GFunc)g_free, NULL);
- g_slist_free(p->response_lines);
- p->response_lines = NULL;
+ g_slist_foreach(response_lines, (GFunc)g_free, NULL);
+ g_slist_free(response_lines);
g_free(final);
-
at_command_destroy(cmd);
-
- p->cmd_bytes_written = 0;
-
- if (g_queue_peek_head(p->command_queue))
- g_at_chat_wakeup_writer(p);
}
struct terminator_info {