Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
46ff6608
Commit
46ff6608
authored
Jul 25, 2022
by
Rucha Deodhar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
This commit is a fixup for MDEV-28762
parent
f1c8749f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
9 deletions
+21
-9
sql/item_jsonfunc.cc
sql/item_jsonfunc.cc
+21
-9
No files found.
sql/item_jsonfunc.cc
View file @
46ff6608
...
@@ -20,6 +20,22 @@
...
@@ -20,6 +20,22 @@
#include "item.h"
#include "item.h"
#include "sql_parse.h" // For check_stack_overrun
#include "sql_parse.h" // For check_stack_overrun
/*
Allocating memory and *also* using it (reading and
writing from it) because some build instructions cause
compiler to optimize out stack_used_up. Since alloca()
here depends on stack_used_up, it doesnt get executed
correctly and causes json_debug_nonembedded to fail
( --error ER_STACK_OVERRUN_NEED_MORE does not occur).
*/
#define ALLOCATE_MEM_ON_STACK(A) do \
{ \
uchar *array= (uchar*)alloca(A); \
array[0]= 1; \
array[0]++; \
array[0] ? array[0]++ : array[0]--; \
} while(0)
/*
/*
Compare ASCII string against the string with the specified
Compare ASCII string against the string with the specified
character set.
character set.
...
@@ -138,9 +154,10 @@ int json_path_parts_compare(
...
@@ -138,9 +154,10 @@ int json_path_parts_compare(
long
arbitrary_var
;
long
arbitrary_var
;
long
stack_used_up
=
(
available_stack_size
(
current_thd
->
thread_stack
,
&
arbitrary_var
));
long
stack_used_up
=
(
available_stack_size
(
current_thd
->
thread_stack
,
&
arbitrary_var
));
DBUG_EXECUTE_IF
(
"json_check_min_stack_requirement"
,
DBUG_EXECUTE_IF
(
"json_check_min_stack_requirement"
,
{
alloca
(
my_thread_stack_size
-
stack_used_up
-
STACK_MIN_SIZE
);});
{
ALLOCATE_MEM_ON_STACK
(
my_thread_stack_size
-
stack_used_up
-
STACK_MIN_SIZE
);});
if
(
check_stack_overrun
(
current_thd
,
STACK_MIN_SIZE
,
NULL
))
if
(
check_stack_overrun
(
current_thd
,
STACK_MIN_SIZE
,
NULL
))
return
1
;
return
1
;
while
(
a
<=
a_end
)
while
(
a
<=
a_end
)
{
{
if
(
b
>
b_end
)
if
(
b
>
b_end
)
...
@@ -1139,15 +1156,10 @@ static int check_contains(json_engine_t *js, json_engine_t *value)
...
@@ -1139,15 +1156,10 @@ static int check_contains(json_engine_t *js, json_engine_t *value)
long
arbitrary_var
;
long
arbitrary_var
;
long
stack_used_up
=
(
available_stack_size
(
current_thd
->
thread_stack
,
&
arbitrary_var
));
long
stack_used_up
=
(
available_stack_size
(
current_thd
->
thread_stack
,
&
arbitrary_var
));
DBUG_EXECUTE_IF
(
"json_check_min_stack_requirement"
,
DBUG_EXECUTE_IF
(
"json_check_min_stack_requirement"
,
{
alloca
(
my_thread_stack_size
-
stack_used_up
-
STACK_MIN_SIZE
);});
{
ALLOCATE_MEM_ON_STACK
(
my_thread_stack_size
-
stack_used_up
-
STACK_MIN_SIZE
);});
if
(
check_stack_overrun
(
current_thd
,
STACK_MIN_SIZE
,
NULL
))
if
(
check_stack_overrun
(
current_thd
,
STACK_MIN_SIZE
,
NULL
))
return
1
;
return
1
;
DBUG_EXECUTE_IF
(
"json_check_min_stack_requirement"
,
{
alloca
(
my_thread_stack_size
-
(
STACK_MIN_SIZE
));});
if
(
check_stack_overrun
(
current_thd
,
STACK_MIN_SIZE
,
NULL
))
return
0
;
switch
(
js
->
value_type
)
switch
(
js
->
value_type
)
{
{
case
JSON_VALUE_OBJECT
:
case
JSON_VALUE_OBJECT
:
...
@@ -2040,7 +2052,7 @@ static int do_merge(String *str, json_engine_t *je1, json_engine_t *je2)
...
@@ -2040,7 +2052,7 @@ static int do_merge(String *str, json_engine_t *je1, json_engine_t *je2)
long
arbitrary_var
;
long
arbitrary_var
;
long
stack_used_up
=
(
available_stack_size
(
current_thd
->
thread_stack
,
&
arbitrary_var
));
long
stack_used_up
=
(
available_stack_size
(
current_thd
->
thread_stack
,
&
arbitrary_var
));
DBUG_EXECUTE_IF
(
"json_check_min_stack_requirement"
,
DBUG_EXECUTE_IF
(
"json_check_min_stack_requirement"
,
{
alloca
(
my_thread_stack_size
-
stack_used_up
-
STACK_MIN_SIZE
);});
{
ALLOCATE_MEM_ON_STACK
(
my_thread_stack_size
-
stack_used_up
-
STACK_MIN_SIZE
);});
if
(
check_stack_overrun
(
current_thd
,
STACK_MIN_SIZE
,
NULL
))
if
(
check_stack_overrun
(
current_thd
,
STACK_MIN_SIZE
,
NULL
))
return
1
;
return
1
;
...
@@ -2379,7 +2391,7 @@ static int do_merge_patch(String *str, json_engine_t *je1, json_engine_t *je2,
...
@@ -2379,7 +2391,7 @@ static int do_merge_patch(String *str, json_engine_t *je1, json_engine_t *je2,
long
arbitrary_var
;
long
arbitrary_var
;
long
stack_used_up
=
(
available_stack_size
(
current_thd
->
thread_stack
,
&
arbitrary_var
));
long
stack_used_up
=
(
available_stack_size
(
current_thd
->
thread_stack
,
&
arbitrary_var
));
DBUG_EXECUTE_IF
(
"json_check_min_stack_requirement"
,
DBUG_EXECUTE_IF
(
"json_check_min_stack_requirement"
,
{
alloca
(
my_thread_stack_size
-
stack_used_up
-
STACK_MIN_SIZE
);});
{
ALLOCATE_MEM_ON_STACK
(
my_thread_stack_size
-
stack_used_up
-
STACK_MIN_SIZE
);});
if
(
check_stack_overrun
(
current_thd
,
STACK_MIN_SIZE
,
NULL
))
if
(
check_stack_overrun
(
current_thd
,
STACK_MIN_SIZE
,
NULL
))
return
1
;
return
1
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment