From ba4b8524e54b93656198f89da3d1754c05e0a8d0 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Sun, 12 Sep 2021 15:13:20 +0300 Subject: [PATCH] Update SQLite.cpp --- module/Library/SQLite.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/Library/SQLite.cpp b/module/Library/SQLite.cpp index 17455e8f..85508b28 100644 --- a/module/Library/SQLite.cpp +++ b/module/Library/SQLite.cpp @@ -454,7 +454,7 @@ LightObj EscapeString(StackStrF & str) // Allocate extra space to make sure there's room for a null terminator since we need it // This is a f* up from SQLite devs not returning the number of written characters from snprintf // So we can figure out if we actually had room for the null terminator or not - b.reserve(static_cast< size_t >(str.mLen * 2)); + b.reserve(static_cast< size_t >(str.mLen * 2 + 1)); // Attempt to escape the specified string sqlite3_snprintf(static_cast(b.capacity()), b.data(), "%q", str.mPtr); // Return the resulted string @@ -482,7 +482,7 @@ LightObj EscapeStringEx(SQChar spec, StackStrF & str) // Allocate a memory buffer std::vector< SQChar > b; // Allocate extra space to make sure there's room for a null terminator since we need it (see above) - b.reserve(static_cast< size_t >(str.mLen * 2)); + b.reserve(static_cast< size_t >(str.mLen * 2 + 1)); // Attempt to escape the specified string sqlite3_snprintf(static_cast(b.capacity()), b.data(), fs, str.mPtr); // Return the resulted string