From a3c50b5f678a4df47354040ebb69f4ad2dd30b5f Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Thu, 25 May 2006 15:06:55 +0000 Subject: fix out-of-bounds array access svn-id: r22627 --- engines/agi/id.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'engines/agi/id.cpp') diff --git a/engines/agi/id.cpp b/engines/agi/id.cpp index 4320864a75..c41d6e7227 100644 --- a/engines/agi/id.cpp +++ b/engines/agi/id.cpp @@ -242,11 +242,12 @@ uint32 match_crc(uint32 crc, char *name, int len) { if (c) *c = 0; - /* Remove spaces at end of line */ + /* Remove spaces/tabs at end of line */ if (strlen(buf)) { - for (c = buf + strlen(buf) - 1; - *c == ' ' || *c == '\t'; *c-- = 0) { - } + int i; + for (i = strlen(buf) - 1; + i >= 0 && (buf[i] == ' ' || buf[i] == '\t'); + buf[i--] = 0) { } } t = strtok(buf, " \t\r\n"); -- cgit v1.2.3