mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-12 12:09:15 +00:00
SCI: correctly put NUL inside SegManager::strncpy() even when using n = 0xFFFFFFFFU
svn-id: r50232
This commit is contained in:
parent
e8d31ccc07
commit
893429d092
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user