From 7bb44ec008965b429a44860b3ec5e3f9114c883a Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Sun, 18 Jun 2017 20:25:12 +0300 Subject: [PATCH] Make builtin formatted strings default to false to avoid trying to perform a format in cases where it can be folled by a following parameters that are not meant to be part of that formatted string. --- include/sqrat/sqratUtil.h | 2 +- modules/irc/Common.cpp | 10 +++++----- modules/irc/Session.cpp | 2 +- modules/mysql/Connection.cpp | 6 +++--- modules/sqlite/Connection.cpp | 4 ++-- source/CoreFuncs.cpp | 2 +- source/Entity/Player.cpp | 12 ++++++------ source/Library/Crypt/Hash.cpp | 8 ++++---- source/Library/Numeric/Math.cpp | 4 ++-- source/Library/String.cpp | 6 +++--- source/Library/System.cpp | 2 +- source/Library/Utils.cpp | 2 +- source/Logger.cpp | 2 +- source/Misc/Broadcast.cpp | 12 ++++++------ source/Tasks.hpp | 2 +- 15 files changed, 38 insertions(+), 38 deletions(-) diff --git a/include/sqrat/sqratUtil.h b/include/sqrat/sqratUtil.h index 6466b40c..00404e00 100644 --- a/include/sqrat/sqratUtil.h +++ b/include/sqrat/sqratUtil.h @@ -1510,7 +1510,7 @@ struct StackStrF ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// Base constructor. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - StackStrF(HSQUIRRELVM vm, SQInteger idx, bool fmt = true, bool dummy = false) + StackStrF(HSQUIRRELVM vm, SQInteger idx, bool fmt = false, bool dummy = false) : mPtr(nullptr) , mLen(-1) , mRes(SQ_OK) diff --git a/modules/irc/Common.cpp b/modules/irc/Common.cpp index e73eee1c..b9b12fdd 100644 --- a/modules/irc/Common.cpp +++ b/modules/irc/Common.cpp @@ -33,7 +33,7 @@ void IrcFreeMem(void * p) static SQInteger SqGetNick(HSQUIRRELVM vm) { // Attempt to retrieve the value from the stack as a string - StackStrF val(vm, 2); + StackStrF val(vm, 2, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { @@ -51,7 +51,7 @@ static SQInteger SqGetNick(HSQUIRRELVM vm) static SQInteger SqGetHost(HSQUIRRELVM vm) { // Attempt to retrieve the value from the stack as a string - StackStrF val(vm, 2); + StackStrF val(vm, 2, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { @@ -69,7 +69,7 @@ static SQInteger SqGetHost(HSQUIRRELVM vm) static SQInteger SqStripColorFromMIRC(HSQUIRRELVM vm) { // Attempt to retrieve the value from the stack as a string - StackStrF val(vm, 2); + StackStrF val(vm, 2, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { @@ -94,7 +94,7 @@ static SQInteger SqStripColorFromMIRC(HSQUIRRELVM vm) static SQInteger SqConvertColorFromMIRC(HSQUIRRELVM vm) { // Attempt to retrieve the value from the stack as a string - StackStrF val(vm, 2); + StackStrF val(vm, 2, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { @@ -119,7 +119,7 @@ static SQInteger SqConvertColorFromMIRC(HSQUIRRELVM vm) static SQInteger SqConvertColorToMIRC(HSQUIRRELVM vm) { // Attempt to retrieve the value from the stack as a string - StackStrF val(vm, 2); + StackStrF val(vm, 2, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { diff --git a/modules/irc/Session.cpp b/modules/irc/Session.cpp index 6519c766..2bf51908 100644 --- a/modules/irc/Session.cpp +++ b/modules/irc/Session.cpp @@ -1048,7 +1048,7 @@ static SQInteger FormattedIrcMessageCmd(HSQUIRRELVM vm, SendIrcMessageFunc send_ } // Attempt to retrieve the value from the stack as a string - StackStrF message(vm, 3); + StackStrF message(vm, 3, true); // Have we failed to retrieve the string? if (SQ_FAILED(message.mRes)) { diff --git a/modules/mysql/Connection.cpp b/modules/mysql/Connection.cpp index d3d25a6e..6675e5b4 100644 --- a/modules/mysql/Connection.cpp +++ b/modules/mysql/Connection.cpp @@ -178,7 +178,7 @@ SQInteger Connection::ExecuteF(HSQUIRRELVM vm) return sq_throwerror(vm, e.what()); } // Attempt to retrieve the value from the stack as a string - StackStrF val(vm, 2); + StackStrF val(vm, 2, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { @@ -245,7 +245,7 @@ SQInteger Connection::InsertF(HSQUIRRELVM vm) return sq_throwerror(vm, e.what()); } // Attempt to retrieve the value from the stack as a string - StackStrF val(vm, 2); + StackStrF val(vm, 2, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { @@ -318,7 +318,7 @@ SQInteger Connection::QueryF(HSQUIRRELVM vm) return sq_throwerror(vm, e.what()); } // Attempt to retrieve the value from the stack as a string - StackStrF val(vm, 2); + StackStrF val(vm, 2, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { diff --git a/modules/sqlite/Connection.cpp b/modules/sqlite/Connection.cpp index 5aaacb56..969e1b78 100644 --- a/modules/sqlite/Connection.cpp +++ b/modules/sqlite/Connection.cpp @@ -346,9 +346,9 @@ void Register_Connection(Table & sqlns) Class< Connection >(sqlns.GetVM(), Typename::Str) // Constructors .Ctor() - .Ctor< const StackStrF & >() + .FmtCtor< const StackStrF & >() .Ctor< const StackStrF &, Int32 >() - .Ctor< const StackStrF &, Int32, const StackStrF & >() + .FmtCtor< const StackStrF &, Int32, const StackStrF & >() // Meta-methods .SquirrelFunc(_SC("_typename"), &Typename::Fn) .Func(_SC("_tostring"), &Connection::ToString) diff --git a/source/CoreFuncs.cpp b/source/CoreFuncs.cpp index 6c786153..105e34a0 100644 --- a/source/CoreFuncs.cpp +++ b/source/CoreFuncs.cpp @@ -25,7 +25,7 @@ static SQInteger SqLoadScript(HSQUIRRELVM vm) // Whether the script execution is delayed SQBool delay = SQFalse; // Attempt to generate the string value - StackStrF val(vm, 3); + StackStrF val(vm, 3, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { diff --git a/source/Entity/Player.cpp b/source/Entity/Player.cpp index 3f903389..093e00d0 100644 --- a/source/Entity/Player.cpp +++ b/source/Entity/Player.cpp @@ -1901,7 +1901,7 @@ SQInteger CPlayer::Msg(HSQUIRRELVM vm) } // Attempt to generate the string value - StackStrF val(vm, msgidx); + StackStrF val(vm, msgidx, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { @@ -1982,7 +1982,7 @@ SQInteger CPlayer::MsgP(HSQUIRRELVM vm) } // Attempt to generate the string value - StackStrF val(vm, 3); + StackStrF val(vm, 3, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { @@ -2088,7 +2088,7 @@ SQInteger CPlayer::MsgEx(HSQUIRRELVM vm) } // Attempt to generate the string value - StackStrF val(vm, msgidx); + StackStrF val(vm, msgidx, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { @@ -2153,7 +2153,7 @@ SQInteger CPlayer::Message(HSQUIRRELVM vm) } // Attempt to generate the string value - StackStrF val(vm, 2); + StackStrF val(vm, 2, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { @@ -2210,7 +2210,7 @@ SQInteger CPlayer::Announce(HSQUIRRELVM vm) } // Attempt to generate the string value - StackStrF val(vm, 2); + StackStrF val(vm, 2, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { @@ -2280,7 +2280,7 @@ SQInteger CPlayer::AnnounceEx(HSQUIRRELVM vm) } // Attempt to generate the string value - StackStrF val(vm, 3); + StackStrF val(vm, 3, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { diff --git a/source/Library/Crypt/Hash.cpp b/source/Library/Crypt/Hash.cpp index b65816d2..ebbd5f6c 100644 --- a/source/Library/Crypt/Hash.cpp +++ b/source/Library/Crypt/Hash.cpp @@ -36,7 +36,7 @@ template < class T > T BaseHash< T >::Algo; template < class T > static SQInteger HashF(HSQUIRRELVM vm) { // Attempt to retrieve the value from the stack as a string - StackStrF val(vm, 2); + StackStrF val(vm, 2, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { @@ -56,7 +56,7 @@ template < class T > static SQInteger HashF(HSQUIRRELVM vm) static SQInteger WhirlpoolF(HSQUIRRELVM vm) { // Attempt to retrieve the value from the stack as a string - StackStrF val(vm, 2); + StackStrF val(vm, 2, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { @@ -94,7 +94,7 @@ static SQInteger WhirlpoolF(HSQUIRRELVM vm) static SQInteger EncodeBase64F(HSQUIRRELVM vm) { // Attempt to retrieve the value from the stack as a string - StackStrF val(vm, 2); + StackStrF val(vm, 2, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { @@ -122,7 +122,7 @@ static SQInteger EncodeBase64F(HSQUIRRELVM vm) static SQInteger DecodeBase64F(HSQUIRRELVM vm) { // Attempt to retrieve the value from the stack as a string - StackStrF val(vm, 2); + StackStrF val(vm, 2, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { diff --git a/source/Library/Numeric/Math.cpp b/source/Library/Numeric/Math.cpp index 3342a8aa..816a0505 100644 --- a/source/Library/Numeric/Math.cpp +++ b/source/Library/Numeric/Math.cpp @@ -153,7 +153,7 @@ static SQInteger SqNan(HSQUIRRELVM vm) return sq_throwerror(vm, "Wrong number of arguments"); } // Attempt to generate the string value - StackStrF val(vm, 2); + StackStrF val(vm, 2, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { @@ -178,7 +178,7 @@ static SQInteger SqNanL(HSQUIRRELVM vm) return sq_throwerror(vm, "Wrong number of arguments"); } // Attempt to generate the string value - StackStrF val(vm, 2); + StackStrF val(vm, 2, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { diff --git a/source/Library/String.cpp b/source/Library/String.cpp index 8e46dc1a..7b1deb80 100644 --- a/source/Library/String.cpp +++ b/source/Library/String.cpp @@ -490,7 +490,7 @@ static SQInteger SplitWhereCharImpl(HSQUIRRELVM vm, int(*fn)(int), bool neg) } // Attempt to retrieve the value from the stack as a string - StackStrF val(vm, 2); + StackStrF val(vm, 2, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { @@ -612,7 +612,7 @@ static SQInteger SqStrExplode(HSQUIRRELVM vm) return sq_throwerror(vm, _SC("Missing string value")); } // Attempt to generate the string value - StackStrF val(vm, 4); + StackStrF val(vm, 4, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { @@ -812,7 +812,7 @@ static CSStr FromArray(Array & arr) static SQInteger StdPrintF(HSQUIRRELVM vm) { // Attempt to retrieve the value from the stack as a string - StackStrF val(vm, 2); + StackStrF val(vm, 2, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { diff --git a/source/Library/System.cpp b/source/Library/System.cpp index 980f964c..f952d595 100644 --- a/source/Library/System.cpp +++ b/source/Library/System.cpp @@ -21,7 +21,7 @@ extern void Register_SysPath(HSQUIRRELVM vm); static SQInteger SqSysExec(HSQUIRRELVM vm) { // Attempt to retrieve the value from the stack as a string - StackStrF val(vm, 2); + StackStrF val(vm, 2, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { diff --git a/source/Library/Utils.cpp b/source/Library/Utils.cpp index 3879d7f1..ec4385e0 100644 --- a/source/Library/Utils.cpp +++ b/source/Library/Utils.cpp @@ -22,7 +22,7 @@ static SQInteger SqExtractIPv4(HSQUIRRELVM vm) return sq_throwerror(vm, "Missing IP address string"); } // Attempt to generate the string value - StackStrF val(vm, 2); + StackStrF val(vm, 2, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { diff --git a/source/Logger.cpp b/source/Logger.cpp index 8167d755..dd7dbfba 100644 --- a/source/Logger.cpp +++ b/source/Logger.cpp @@ -539,7 +539,7 @@ template < Uint8 L, bool S > static SQInteger LogBasicMessage(HSQUIRRELVM vm) return sq_throwerror(vm, "Missing message value"); } // Attempt to generate the string value - StackStrF val(vm, 2); + StackStrF val(vm, 2, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { diff --git a/source/Misc/Broadcast.cpp b/source/Misc/Broadcast.cpp index 03ed4cf5..7db45c0c 100644 --- a/source/Misc/Broadcast.cpp +++ b/source/Misc/Broadcast.cpp @@ -259,7 +259,7 @@ static SQInteger SqBroadcastMsg(HSQUIRRELVM vm) } // Attempt to generate the string value - StackStrF val(vm, msgidx); + StackStrF val(vm, msgidx, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { @@ -339,7 +339,7 @@ static SQInteger SqBroadcastMsgP(HSQUIRRELVM vm) } // Attempt to generate the string value - StackStrF val(vm, 3); + StackStrF val(vm, 3, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { @@ -444,7 +444,7 @@ static SQInteger SqBroadcastMsgEx(HSQUIRRELVM vm) } // Attempt to generate the string value - StackStrF val(vm, msgidx); + StackStrF val(vm, msgidx, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { @@ -508,7 +508,7 @@ static SQInteger SqBroadcastMessage(HSQUIRRELVM vm) } // Attempt to generate the string value - StackStrF val(vm, 2); + StackStrF val(vm, 2, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { @@ -564,7 +564,7 @@ static SQInteger SqBroadcastAnnounce(HSQUIRRELVM vm) } // Attempt to generate the string value - StackStrF val(vm, 2); + StackStrF val(vm, 2, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { @@ -641,7 +641,7 @@ static SQInteger SqBroadcastAnnounceEx(HSQUIRRELVM vm) } // Attempt to generate the string value - StackStrF val(vm, 3); + StackStrF val(vm, 3, true); // Have we failed to retrieve the string? if (SQ_FAILED(val.mRes)) { diff --git a/source/Tasks.hpp b/source/Tasks.hpp index 9b3a0e04..d5841595 100644 --- a/source/Tasks.hpp +++ b/source/Tasks.hpp @@ -499,7 +499,7 @@ public: return sq_throwerror(vm, e.what()); } // Attempt to generate the string value - const StackStrF tag(vm, 2); + const StackStrF tag(vm, 2, true); // Have we failed to retrieve the string? if (SQ_FAILED(tag.mRes)) {