Fix a crash with unsolicited notifications
authorDenis Kenzior <denkenz@gmail.com>
Tue, 21 Jul 2009 19:38:29 +0000 (14:38 -0500)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 21 Jul 2009 19:45:01 +0000 (21:45 +0200)
When a line comes in from the modem, we check against prefixes
in outstanding commands and unsolicited notifications.  If the
outstanding command has not yet been sent (cmd_bytes_written == 0),
we still check it resulting in access violation.

gatchat/gatchat.c

index 616f843..15cc934 100644 (file)
@@ -466,7 +466,7 @@ static void have_line(GAtChat *p, gboolean strip_preceding)
 
        cmd = g_queue_peek_head(p->command_queue);
 
-       if (cmd) {
+       if (cmd && p->cmd_bytes_written > 0) {
                char c = cmd->cmd[p->cmd_bytes_written - 1];
 
                /* We check that we have submitted a terminator, in which case