mirror of
https://github.com/MariaDB/server.git
synced 2025-02-01 03:21:53 +01:00
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
This commit is contained in:
parent
d3dc52e47c
commit
a6b8bfcafd
1 changed files with 12 additions and 6 deletions
|
@ -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];
|
||||
|
|
Loading…
Add table
Reference in a new issue