diff options
author | Filippos Karapetis | 2010-01-24 11:00:21 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-01-24 11:00:21 +0000 |
commit | 135294068848fbe476658af4765f85fee75fa57f (patch) | |
tree | e57481a7a98198b0a9649417a3ff36c30af4ced3 /engines/sci/engine/kstring.cpp | |
parent | d0b8a8e468017ce9096729a78fe3b19ff4f89a68 (diff) | |
download | scummvm-rg350-135294068848fbe476658af4765f85fee75fa57f.tar.gz scummvm-rg350-135294068848fbe476658af4765f85fee75fa57f.tar.bz2 scummvm-rg350-135294068848fbe476658af4765f85fee75fa57f.zip |
Replaced CHECK_OVERFLOW1 with asserts
svn-id: r47496
Diffstat (limited to 'engines/sci/engine/kstring.cpp')
-rw-r--r-- | engines/sci/engine/kstring.cpp | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp index 2e4ecce802..03b44f4b4e 100644 --- a/engines/sci/engine/kstring.cpp +++ b/engines/sci/engine/kstring.cpp @@ -179,12 +179,6 @@ reg_t kReadNumber(EngineState *s, int argc, reg_t *argv) { #define ALIGN_LEFT -1 #define ALIGN_CENTRE 2 -#define CHECK_OVERFLOW1(pt, size, rv) \ - if (((pt) - (targetbuf)) + (size) > maxsize) { \ - error("String expansion exceeded heap boundaries"); \ - return rv;\ - } - /* Format(targ_address, textresnr, index_inside_res, ...) ** or ** Format(targ_address, heap_text_addr, ...) @@ -229,7 +223,7 @@ reg_t kFormat(EngineState *s, int argc, reg_t *argv) { while ((xfer = *source++)) { if (xfer == '%') { if (mode == 1) { - CHECK_OVERFLOW1(target, 2, NULL_REG); + assert((target - targetbuf) + 2 <= maxsize); *target++ = '%'; /* Literal % by using "%%" */ mode = 0; } else { @@ -274,7 +268,7 @@ reg_t kFormat(EngineState *s, int argc, reg_t *argv) { } else str_leng = 0; - CHECK_OVERFLOW1(target, str_leng + 1, NULL_REG); + assert((target - targetbuf) + str_leng + 1 <= maxsize); switch (xfer) { case 's': { /* Copy string */ @@ -283,7 +277,7 @@ reg_t kFormat(EngineState *s, int argc, reg_t *argv) { arguments[paramindex + 1]); int slen = strlen(tempsource.c_str()); int extralen = str_leng - slen; - CHECK_OVERFLOW1(target, extralen, NULL_REG); + assert((target - targetbuf) + extralen <= maxsize); if (extralen < 0) extralen = 0; @@ -336,7 +330,7 @@ reg_t kFormat(EngineState *s, int argc, reg_t *argv) { break; case 'c': { /* insert character */ - CHECK_OVERFLOW1(target, 2, NULL_REG); + assert((target - targetbuf) + 2 <= maxsize); if (align >= 0) while (str_leng-- > 1) *target++ = ' '; /* Format into the text */ @@ -362,7 +356,7 @@ reg_t kFormat(EngineState *s, int argc, reg_t *argv) { target += sprintf(target, format_string, val); paramindex++; - CHECK_OVERFLOW1(target, 0, NULL_REG); + assert((target - targetbuf) <= maxsize); unsigned_var = 0; @@ -407,8 +401,6 @@ reg_t kFormat(EngineState *s, int argc, reg_t *argv) { return dest; /* Return target addr */ } -#undef CHECK_OVERFLOW1 - reg_t kStrLen(EngineState *s, int argc, reg_t *argv) { return make_reg(0, s->_segMan->strlen(argv[0])); } |