1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-12 17:19:09 +00:00

(svn r25527) -Fix[FS#5621]: strndup should not examine strings beyond its upper limit.

This commit is contained in:
alberth
2013-06-30 08:29:51 +00:00
parent 92f276f26d
commit 631540c400

View File

@@ -560,10 +560,9 @@ size_t Utf8TrimString(char *s, size_t maxlen)
}
#ifdef DEFINE_STRNDUP
#include "core/math_func.hpp"
char *strndup(const char *s, size_t len)
{
len = min(strlen(s), len);
len = ttd_strnlen(s, len);
char *tmp = CallocT<char>(len + 1);
memcpy(tmp, s, len);
return tmp;