Skip to content

Commit 88f7b8c

Browse files
committed
Fix potential overflow in D3_ISO8859_1toUTF8()
unlikely to happen with the current usages (for the user-provided player name in the dhewm3 settings menu)
1 parent f28c7a9 commit 88f7b8c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

neo/idlib/Str.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1969,6 +1969,12 @@ char * D3_ISO8859_1toUTF8( const char* isoStr, char *utf8buf, int utf8bufLen )
19691969
++str;
19701970
}
19711971
}
1972+
if(i > n) {
1973+
// last written codepoint used two chars
1974+
// => would be out of bounds with terminating \0
1975+
// => utf8buf was too short, return NULL
1976+
return NULL;
1977+
}
19721978
buffer[i] = '\0';
19731979
return utf8buf;
19741980
}

0 commit comments

Comments
 (0)