OSDN Git Service

glsl: fix heap-use-after-free in ast_declarator_list::hir()
authorSamuel Iglesias Gonsálvez <siglesias@igalia.com>
Thu, 9 Feb 2017 12:54:46 +0000 (13:54 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Wed, 1 Mar 2017 13:34:42 +0000 (13:34 +0000)
commitc20881661f8195c79503ee36022368798db24de1
tree19f9ff0c212305579ce096420df49a72584ae37e
parent6d2c4e940e5f6d80c94cc0ee9d26fee50202a4e0
glsl: fix heap-use-after-free in ast_declarator_list::hir()

The get_variable_being_redeclared() function can free 'var' because
a re-declaration of an unsized array variable can establish the size, so
we set the array type to the 'earlier' declaration and free 'var' as it is
not needed anymore.

However, the same 'var' is referenced later in ast_declarator_list::hir().

This patch fixes it by picking the ir_variable_mode from the proper
ir_variable.

This error was detected by Address Sanitizer.

Signed-off-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Suggested-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99677
Cc: "17.0" <mesa-stable@lists.freedesktop.org>
Cc: "13.0" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit a73a61893323c74f38b1baa30d63a5cc665b7b58)
src/compiler/glsl/ast_to_hir.cpp