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 616f843a6ac9eba0c20cfcf8f6fa8ecb971709fb..15cc934c5251064df5134283320bb3b3c276d9df 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