mirror of
https://github.com/MariaDB/server.git
synced 2025-01-21 06:22:28 +01:00
a17fb97b9b
SP variables A function call may end without throwing an error or without setting the return value. This can happen when e.g. an error occurs while calculating the return value. Fixed by setting the value to NULL when error occurs during evaluation of an expression.
47 lines
1.1 KiB
Text
47 lines
1.1 KiB
Text
#
|
|
# Bug #47412: Valgrind warnings / user can read uninitalized memory
|
|
# using SP variables
|
|
#
|
|
CREATE SCHEMA testdb;
|
|
USE testdb;
|
|
CREATE FUNCTION f2 () RETURNS INTEGER
|
|
BEGIN
|
|
DECLARE CONTINUE HANDLER FOR SQLSTATE '42000' SET @aux = 1;
|
|
RETURN f_not_exists () ;
|
|
END|
|
|
CREATE PROCEDURE p3 ( arg1 VARCHAR(32) )
|
|
BEGIN
|
|
CALL p_not_exists ( );
|
|
END|
|
|
# should not return valgrind warnings
|
|
CALL p3 ( f2 () );
|
|
ERROR 42000: PROCEDURE testdb.p_not_exists does not exist
|
|
DROP SCHEMA testdb;
|
|
CREATE SCHEMA testdb;
|
|
USE testdb;
|
|
CREATE FUNCTION f2 () RETURNS INTEGER
|
|
BEGIN
|
|
DECLARE CONTINUE HANDLER FOR SQLSTATE '42000' SET @aux = 1;
|
|
RETURN f_not_exists () ;
|
|
END|
|
|
CREATE PROCEDURE p3 ( arg2 INTEGER )
|
|
BEGIN
|
|
CALL p_not_exists ( );
|
|
END|
|
|
# should not return valgrind warnings
|
|
CALL p3 ( f2 () );
|
|
ERROR 42000: PROCEDURE testdb.p_not_exists does not exist
|
|
DROP SCHEMA testdb;
|
|
CREATE SCHEMA testdb;
|
|
USE testdb;
|
|
CREATE FUNCTION f2 () RETURNS INTEGER
|
|
BEGIN
|
|
DECLARE CONTINUE HANDLER FOR SQLSTATE '42000' SET @aux = 1;
|
|
RETURN f_not_exists () ;
|
|
END|
|
|
# should not return valgrind warnings
|
|
SELECT f2 ();
|
|
f2 ()
|
|
NULL
|
|
DROP SCHEMA testdb;
|
|
End of 5.1 tests
|