mirror of
https://github.com/MariaDB/server.git
synced 2026-05-06 23:25:34 +02:00
Bug #47412: Valgrind warnings / user can read uninitalized memory using
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.
This commit is contained in:
parent
9a5a77eb68
commit
8363e26659
3 changed files with 125 additions and 14 deletions
61
mysql-test/t/sp-bugs.test
Normal file
61
mysql-test/t/sp-bugs.test
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
# Test file for stored procedure bugfixes
|
||||
|
||||
--echo #
|
||||
--echo # Bug #47412: Valgrind warnings / user can read uninitalized memory
|
||||
--echo # using SP variables
|
||||
--echo #
|
||||
|
||||
CREATE SCHEMA testdb;
|
||||
USE testdb;
|
||||
DELIMITER |;
|
||||
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|
|
||||
DELIMITER ;|
|
||||
--echo # should not return valgrind warnings
|
||||
--error ER_SP_DOES_NOT_EXIST
|
||||
CALL p3 ( f2 () );
|
||||
|
||||
DROP SCHEMA testdb;
|
||||
|
||||
CREATE SCHEMA testdb;
|
||||
USE testdb;
|
||||
DELIMITER |;
|
||||
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|
|
||||
DELIMITER ;|
|
||||
--echo # should not return valgrind warnings
|
||||
--error ER_SP_DOES_NOT_EXIST
|
||||
CALL p3 ( f2 () );
|
||||
|
||||
DROP SCHEMA testdb;
|
||||
|
||||
CREATE SCHEMA testdb;
|
||||
USE testdb;
|
||||
DELIMITER |;
|
||||
CREATE FUNCTION f2 () RETURNS INTEGER
|
||||
BEGIN
|
||||
DECLARE CONTINUE HANDLER FOR SQLSTATE '42000' SET @aux = 1;
|
||||
RETURN f_not_exists () ;
|
||||
END|
|
||||
DELIMITER ;|
|
||||
--echo # should not return valgrind warnings
|
||||
SELECT f2 ();
|
||||
|
||||
DROP SCHEMA testdb;
|
||||
|
||||
|
||||
--echo End of 5.1 tests
|
||||
Loading…
Add table
Add a link
Reference in a new issue