From e346f5ffb4f296bd9a94e1308ce4d1245145d8d8 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 20 Mar 2022 11:18:32 +0100 Subject: [PATCH] Make CreateScript use std::string to help prevent issues. --- src/ScriptResolving/AngelScript/AngelScriptResolver.cpp | 4 ++-- src/ScriptResolving/AngelScript/AngelScriptResolver.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ScriptResolving/AngelScript/AngelScriptResolver.cpp b/src/ScriptResolving/AngelScript/AngelScriptResolver.cpp index 5c12e28..5fc834e 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptResolver.cpp +++ b/src/ScriptResolving/AngelScript/AngelScriptResolver.cpp @@ -320,8 +320,8 @@ void AngelScriptResolver::RegisterScriptType(asITypeInfo* typeInfo, const ArbUt: break; } } -void AngelScriptResolver::CreateScript(const char* name, const char* script) { - EnsureGreater(_builder.AddSectionFromMemory(name, script), 0); +void AngelScriptResolver::CreateScript(const std::string& name, const std::string& script) { + EnsureGreater(_builder.AddSectionFromMemory(name.c_str(), script.c_str()), 0); } void AngelScriptResolver::WriteByteCodeToFile(const char* file, bool stripDebugInfo) { FILE* wFile = nullptr; diff --git a/src/ScriptResolving/AngelScript/AngelScriptResolver.hpp b/src/ScriptResolving/AngelScript/AngelScriptResolver.hpp index 2c72872..73f8cc1 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptResolver.hpp +++ b/src/ScriptResolving/AngelScript/AngelScriptResolver.hpp @@ -58,7 +58,7 @@ public: void Initialize(CreatureLib::Battling::BattleLibrary* library) override { Initialize(library, true); } void Initialize(CreatureLib::Battling::BattleLibrary* library, bool includeStandard); - void CreateScript(const char* name, const char* script); + void CreateScript(const std::string& name, const std::string& script); inline void SetSourceDirectory(std::string const& path) noexcept { _sourceDirectory = path; } const asIScriptModule* GetMainModule() const noexcept { return _mainModule; } CScriptBuilder& GetBuilder() noexcept { return _builder; }