From d059dd736867f5260c7e1663ea09835055b556e0 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Sat, 5 Dec 2015 21:04:02 +0100 Subject: [PATCH] Fix memory error when a plain string argument is parsed. Parsing memory, not added in CalcLen, is added in CheckMemory. Adding also the file length. modified: storage/connect/jsonudf.cpp --- storage/connect/jsonudf.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/storage/connect/jsonudf.cpp b/storage/connect/jsonudf.cpp index 4fa21b84224..6aa82faf657 100644 --- a/storage/connect/jsonudf.cpp +++ b/storage/connect/jsonudf.cpp @@ -1426,10 +1426,11 @@ static my_bool CheckMemory(PGLOBAL g, UDF_INIT *initid, UDF_ARGS *args, uint n, char *p = args->args[0]; // Is this a file name? - if (strchr("[{ \t\r\n", *p) || !(len = GetFileLength(p))) - len = args->lengths[0]; + if (!strchr("[{ \t\r\n", *p) && (len = GetFileLength(p))) + ml += len * (M + 1); + else + ml += args->lengths[0] * M; - ml += len * M; // Was not done in CalcLen } // endif b if (ml > g->Sarea_Size) {