diff options
author | rubidium <rubidium@openttd.org> | 2014-04-25 17:35:29 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2014-04-25 17:35:29 +0000 |
commit | 6ad6845f8ca35920a7e7b61f1007ef388ccbb598 (patch) | |
tree | 441bbbf13a300cb89894ba006ad7e51a5835df78 /src/townname.cpp | |
parent | 9ed12b0f07edb342aaff21c130d325fd158a9d5b (diff) | |
download | openttd-6ad6845f8ca35920a7e7b61f1007ef388ccbb598.tar.xz |
(svn r26510) -Codechange: use memcpy instead of strncpy in the town name replace word function since we never want to add a '\0' anyway, and we know the exact length too
Diffstat (limited to 'src/townname.cpp')
-rw-r--r-- | src/townname.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/townname.cpp b/src/townname.cpp index 99dd99821..f3a4e5cbb 100644 --- a/src/townname.cpp +++ b/src/townname.cpp @@ -202,7 +202,8 @@ static inline int32 SeedChanceBias(byte shift_by, int max, uint32 seed, int bias */ static void ReplaceWords(const char *org, const char *rep, char *buf) { - if (strncmp(buf, org, 4) == 0) strncpy(buf, rep, 4); // Safe as the string in buf is always more than 4 characters long. + assert(strlen(org) == 4 && strlen(rep) == 4 && strlen(buf) >= 4); + if (strncmp(buf, org, 4) == 0) memcpy(buf, rep, 4); // Safe as the string in buf is always more than 4 characters long. } |