aboutsummaryrefslogtreecommitdiff
path: root/kyra
diff options
context:
space:
mode:
authorTorbjörn Andersson2005-10-15 06:26:53 +0000
committerTorbjörn Andersson2005-10-15 06:26:53 +0000
commit7aec70c3952c76235c83e162069c24d89c7c52fc (patch)
tree80e6f190db6d4dae8e713607e74f3b615bd33cea /kyra
parentb7e72737d330a63b77692355f6aae527f606adcd (diff)
downloadscummvm-rg350-7aec70c3952c76235c83e162069c24d89c7c52fc.tar.gz
scummvm-rg350-7aec70c3952c76235c83e162069c24d89c7c52fc.tar.bz2
scummvm-rg350-7aec70c3952c76235c83e162069c24d89c7c52fc.zip
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
Diffstat (limited to 'kyra')
-rw-r--r--kyra/kyra.cpp12
-rw-r--r--kyra/resource.cpp2
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);