diff options
author | Peter Powell <petpow@saberuk.com> | 2018-01-01 23:56:35 +0000 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2018-01-03 12:38:40 +0000 |
commit | 372bb6ec31e26908966ff553b782c9a24a07db6a (patch) | |
tree | 799f5496c4658a753af2c6b4d8e6ada2f3152ee5 /include/inspircd.h | |
parent | 5c6352dd9a642bdb1f5fa2727a41dea9197b4536 (diff) |
Make InspIRCd::Format return std::string instead of const char*.
Using the latter is problematic as if you don't copy the return
value before calling Format again your formatted message will be
overwritten by something else. This bug was observed in m_callerid
where InspIRCd::Format was being used for formatting two arguments
the latter of which was being overwritten with the former.
We could have preserved the return type and just copied the string
but then callers would have had to deallocate the string once they
have finished with it which is an undesirabable burden to put on
callers.
Diffstat (limited to 'include/inspircd.h')
-rw-r--r-- | include/inspircd.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/include/inspircd.h b/include/inspircd.h index 40c368106..bdbcdb20d 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -407,8 +407,8 @@ class CoreExport InspIRCd * @param ... A variable number of format arguments. * @return The formatted string */ - static const char* Format(const char* formatString, ...) CUSTOM_PRINTF(1, 2); - static const char* Format(va_list &vaList, const char* formatString) CUSTOM_PRINTF(2, 0); + static std::string Format(const char* formatString, ...) CUSTOM_PRINTF(1, 2); + static std::string Format(va_list& vaList, const char* formatString) CUSTOM_PRINTF(2, 0); /** Determines whether a nickname is valid. */ TR1NS::function<bool(const std::string&)> IsNick; |