diff options
author | Willem Jan Palenstijn | 2011-02-28 20:31:33 +0100 |
---|---|---|
committer | Willem Jan Palenstijn | 2011-02-28 21:37:12 +0100 |
commit | ce288024b495032d15940dc4b93069a3bc845f48 (patch) | |
tree | 27fdc441bdf05913cb553d56acbd7fea28c0c87f /engines/sci | |
parent | 3574235ba4b3888493bd978ff7fe5bc462072870 (diff) | |
download | scummvm-rg350-ce288024b495032d15940dc4b93069a3bc845f48.tar.gz scummvm-rg350-ce288024b495032d15940dc4b93069a3bc845f48.tar.bz2 scummvm-rg350-ce288024b495032d15940dc4b93069a3bc845f48.zip |
SCI: Fix crash with hunk refs in logkernel output
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/engine/vm.cpp | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 43d38a4979..e00ec59196 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -632,18 +632,41 @@ static void logKernelCall(const KernelFunction *kernelCall, const KernelSubFunct debugN(" (%s)", s->_segMan->getObjectName(argv[parmNr])); break; case SIG_TYPE_REFERENCE: - if (kernelCall->function == kSaid) { - SegmentRef saidSpec = s->_segMan->dereference(argv[parmNr]); - if (saidSpec.isRaw) { - debugN(" ('"); - g_sci->getVocabulary()->debugDecipherSaidBlock(saidSpec.raw); - debugN("')"); + { + SegmentObj *mobj = s->_segMan->getSegmentObj(argv[parmNr].segment); + switch (mobj->getType()) { + case SEG_TYPE_HUNK: + { + HunkTable *ht = (HunkTable*)mobj; + int index = argv[parmNr].offset; + if (ht->isValidEntry(index)) { + // NOTE: This ", deleted" isn't as useful as it could + // be because it prints the status _after_ the kernel + // call. + debugN(" ('%s' hunk%s)", ht->_table[index].type, ht->_table[index].mem ? "" : ", deleted"); + } else + debugN(" (INVALID hunk ref)"); + break; + } + default: + // TODO: Any other segment types which could + // use special handling? + + if (kernelCall->function == kSaid) { + SegmentRef saidSpec = s->_segMan->dereference(argv[parmNr]); + if (saidSpec.isRaw) { + debugN(" ('"); + g_sci->getVocabulary()->debugDecipherSaidBlock(saidSpec.raw); + debugN("')"); + } else { + debugN(" (non-raw said-spec)"); + } } else { - debugN(" (non-raw said-spec)"); + debugN(" ('%s')", s->_segMan->getString(argv[parmNr]).c_str()); } - } else { - debugN(" ('%s')", s->_segMan->getString(argv[parmNr]).c_str()); + break; } + } default: break; } |