From 7aec70c3952c76235c83e162069c24d89c7c52fc Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sat, 15 Oct 2005 06:26:53 +0000 Subject: Fixed a bug in the Kyra CD intro that caused ScummVM to crash when compiled with GCC 4. (The string buffer for the file name was too short, which caused a write to another variable's address to overwrite the terminating zero at the end of the string.) svn-id: r19093 --- kyra/kyra.cpp | 12 +++--------- kyra/resource.cpp | 2 -- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/kyra/kyra.cpp b/kyra/kyra.cpp index 4ccce0f99b..84bfd4ca92 100644 --- a/kyra/kyra.cpp +++ b/kyra/kyra.cpp @@ -926,15 +926,9 @@ void KyraEngine::snd_playSoundEffect(int track) { void KyraEngine::snd_playVoiceFile(int id) { debug(9, "KyraEngine::snd_playVoiceFile(%d)", id); - char vocFile[7]; - memset(vocFile, 0, sizeof(char)*7); - if (id < 10) { - sprintf(vocFile, "00%d.VOC", id); - } else if (id < 100) { - sprintf(vocFile, "0%d.VOC", id); - } else { - sprintf(vocFile, "%d.VOC", id); - } + char vocFile[8]; + assert(id >= 0 && id < 1000); + sprintf(vocFile, "%03d.VOC", id); uint32 fileSize = 0; byte *fileData = 0; fileData = _res->fileData(vocFile, &fileSize); diff --git a/kyra/resource.cpp b/kyra/resource.cpp index 3a86b945de..88f78b334d 100644 --- a/kyra/resource.cpp +++ b/kyra/resource.cpp @@ -159,8 +159,6 @@ uint8* Resource::fileData(const char* file, uint32* size) { buffer = new uint8[*size]; assert(buffer); - // TODO: maybe remove this again, this is only - // because I had problems when using gcc 4.0.1 const uint8 *from = start->_file->getFile(file); assert(from); -- cgit v1.2.3