diff options
author | Martin Kiewitz | 2010-06-24 20:40:57 +0000 |
---|---|---|
committer | Martin Kiewitz | 2010-06-24 20:40:57 +0000 |
commit | 893429d092cd10a490d14beff74217a6080d1f5a (patch) | |
tree | 1a3fd83a9f6de381bbd440982d8cbc2111cdff08 /engines/sci/engine/seg_manager.cpp | |
parent | e8d31ccc078b4144ae073881b79517bae2b0cb07 (diff) | |
download | scummvm-rg350-893429d092cd10a490d14beff74217a6080d1f5a.tar.gz scummvm-rg350-893429d092cd10a490d14beff74217a6080d1f5a.tar.bz2 scummvm-rg350-893429d092cd10a490d14beff74217a6080d1f5a.zip |
SCI: correctly put NUL inside SegManager::strncpy() even when using n = 0xFFFFFFFFU
svn-id: r50232
Diffstat (limited to 'engines/sci/engine/seg_manager.cpp')
-rw-r--r-- | engines/sci/engine/seg_manager.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp index b464438553..2178b42744 100644 --- a/engines/sci/engine/seg_manager.cpp +++ b/engines/sci/engine/seg_manager.cpp @@ -649,14 +649,15 @@ void SegManager::strncpy(reg_t dest, const char* src, size_t n) { ::strncpy((char *)dest_r.raw, src, n); } else { // raw -> non-raw - for (uint i = 0; i < n; i++) { + uint i; + for (i = 0; i < n; i++) { setChar(dest_r, i, src[i]); if (!src[i]) break; } // Put an ending NUL to terminate the string - if ((size_t)dest_r.maxSize > n) - setChar(dest_r, n, 0); + if ((size_t)dest_r.maxSize > i) + setChar(dest_r, i, 0); } } |