diff options
author | Olivier Bertrand <bertrandop@gmail.com> | 2015-12-05 17:30:03 +0100 |
---|---|---|
committer | Olivier Bertrand <bertrandop@gmail.com> | 2015-12-05 17:30:03 +0100 |
commit | a6b8bfcafd71804244954ddd4f9cdd0fc4ba7e68 (patch) | |
tree | c11e7eac2ea627e9a1a655b903cd001e88c1fbc5 /storage | |
parent | d3dc52e47c3a048d9ee8449bc7b394026e3f7d8c (diff) | |
download | mariadb-git-a6b8bfcafd71804244954ddd4f9cdd0fc4ba7e68.tar.gz |
Fix memory error when a plain string argument is parsed.
Parsing memory, not added in CalcLen, is added in CheckMemory.
Oups... last commit was buggy
modified: storage/connect/jsonudf.cpp
Diffstat (limited to 'storage')
-rw-r--r-- | storage/connect/jsonudf.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/storage/connect/jsonudf.cpp b/storage/connect/jsonudf.cpp index f66c52139f9..4fa21b84224 100644 --- a/storage/connect/jsonudf.cpp +++ b/storage/connect/jsonudf.cpp @@ -1414,15 +1414,23 @@ static my_bool CheckMemory(PGLOBAL g, UDF_INIT *initid, UDF_ARGS *args, uint n, unsigned long rl, ml; my_bool b = false; - n = MY_MIN(n, args->arg_count); + n = MY_MIN(n, args->arg_count); for (uint i = 0; i < n; i++) if (IsJson(args, i) == 2 || - (b == (m && !i && args->arg_type[0] == STRING_RESULT && !IsJson(args, 0)))) { + (b = (m && !i && args->arg_type[0] == STRING_RESULT && !IsJson(args, 0)))) { if (CalcLen(args, obj, rl, ml, mod)) return true; - else if (b) - ml += args->lengths[0] * M; // Was not done in CalcLen + else if (b) { + ulong len; + char *p = args->args[0]; + + // Is this a file name? + if (strchr("[{ \t\r\n", *p) || !(len = GetFileLength(p))) + len = args->lengths[0]; + + ml += len * M; // Was not done in CalcLen + } // endif b if (ml > g->Sarea_Size) { free(g->Sarea); @@ -3813,8 +3821,6 @@ char *jfile_make(UDF_INIT *initid, UDF_ARGS *args, char *result, } else if (initid->const_item) g->N = 1; - PlugSubSet(g, g->Sarea, g->Sarea_Size); - if ((n = IsJson(args, 0)) == 3) { // Get default file name and pretty PBSON bsp = (PBSON)args->args[0]; |