diff options
author | Travis Howell | 2004-09-16 13:51:03 +0000 |
---|---|---|
committer | Travis Howell | 2004-09-16 13:51:03 +0000 |
commit | 0a320ac7aff085a791c6b865fcc23c5659a2b881 (patch) | |
tree | 02d3c045016d3361afbe64c23ae0a41c0d45c2b2 /scumm | |
parent | 31772ea47d00b23dc0de73e52aa39933d59dd86e (diff) | |
download | scummvm-rg350-0a320ac7aff085a791c6b865fcc23c5659a2b881.tar.gz scummvm-rg350-0a320ac7aff085a791c6b865fcc23c5659a2b881.tar.bz2 scummvm-rg350-0a320ac7aff085a791c6b865fcc23c5659a2b881.zip |
Correct array size read
svn-id: r15140
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/script_v6.cpp | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp index 4387b1f94c..142e398883 100644 --- a/scumm/script_v6.cpp +++ b/scumm/script_v6.cpp @@ -2996,7 +2996,7 @@ void ScummEngine_v6::o6_shuffle() { void ScummEngine_v6::o6_pickVarRandom() { int num; int args[100]; - int var_C, var_A; + int dim1; num = getStackList(args, ARRAYSIZE(args)); int value = fetchScriptWord(); @@ -3018,18 +3018,12 @@ void ScummEngine_v6::o6_pickVarRandom() { num = readArray(value, 0, 0); - byte *ptr = getResourceAddress(rtString, readVar(value)); - if (_version >= 7) { - var_A = READ_LE_UINT32(ptr + 4); - var_C = READ_LE_UINT32(ptr + 8); - } else { - var_A = READ_LE_UINT16(ptr + 2); - var_C = READ_LE_UINT16(ptr + 4); - } + ArrayHeader *ah = (ArrayHeader *)getResourceAddress(rtString, readVar(value)); + dim1 = FROM_LE_16(ah->dim1) - 1; - if (var_A-1 <= num) { + if (dim1 <= num) { int16 var_2 = readArray(value, 0, num - 1); - shuffleArray(value, 1, var_A - 1); + shuffleArray(value, 1, dim1); if (readArray(value, 0, 1) == var_2) { num = 2; } else { |