summaryrefslogtreecommitdiff
path: root/src/strings.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-10-28 14:42:31 +0000
committerrubidium <rubidium@openttd.org>2008-10-28 14:42:31 +0000
commit0d2f84e117e06db09414ec55b0c0c79f3e8c7bdb (patch)
treeb5fc23e46516c5f53edc37ad11559ac6e8586d4c /src/strings.cpp
parent83e1a083d1e72dd97d4da87f3f5b055856e26b02 (diff)
downloadopenttd-0d2f84e117e06db09414ec55b0c0c79f3e8c7bdb.tar.xz
(svn r14540) -Codechange: introduce [v]seprintf which are like [v]snprintf but do return the number of characters written instead of the number of characters that would be written; as size_t is unsigned substraction can cause integer underflows quite quickly.
Diffstat (limited to 'src/strings.cpp')
-rw-r--r--src/strings.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/strings.cpp b/src/strings.cpp
index ee0ad8625..da08581a0 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -271,7 +271,7 @@ static char *FormatNoCommaNumber(char *buff, int64 number, const char *last)
static char *FormatHexNumber(char *buff, int64 number, const char *last)
{
- return buff + snprintf(buff, last - buff, "0x%x", (uint32)number);
+ return buff + seprintf(buff, last, "0x%x", (uint32)number);
}
static char *FormatYmdString(char *buff, Date date, const char* last)
@@ -1198,8 +1198,8 @@ static char *GetSpecialNameString(char *buff, int ind, const int64 *argv, const
/* resolution size? */
if (IsInsideMM(ind, (SPECSTR_RESOLUTION_START - 0x70E4), (SPECSTR_RESOLUTION_END - 0x70E4) + 1)) {
int i = ind - (SPECSTR_RESOLUTION_START - 0x70E4);
- buff += snprintf(
- buff, last - buff + 1, "%dx%d", _resolutions[i].width, _resolutions[i].height
+ buff += seprintf(
+ buff, last, "%dx%d", _resolutions[i].width, _resolutions[i].height
);
return buff;
}