From 756bfd0ad16f4d30c0844653461edc6afd7ad0e7 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 20 Feb 2019 16:30:35 -0500 Subject: [PATCH] Allocate empty function name in the string pool. Inside the grammar for function_identifier if the .function is null an empty function name is allocated. This is allocated on the stack and passed into TFunction as a pointer. TFunction just stores that pointer. Later, when we access the name we will receive an invalid usage of a stack allocated variable. This CL switches to using NewPoolTStringn for the empty function name. --- glslang/MachineIndependent/glslang.y | 4 ++-- glslang/MachineIndependent/glslang_tab.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/glslang/MachineIndependent/glslang.y b/glslang/MachineIndependent/glslang.y index d6e5091..90be7a7 100755 --- a/glslang/MachineIndependent/glslang.y +++ b/glslang/MachineIndependent/glslang.y @@ -473,8 +473,8 @@ function_identifier if ($$.function == 0) { // error recover - TString empty(""); - $$.function = new TFunction(&empty, TType(EbtVoid), EOpNull); + TString* empty = NewPoolTString(""); + $$.function = new TFunction(empty, TType(EbtVoid), EOpNull); } } | non_uniform_qualifier { diff --git a/glslang/MachineIndependent/glslang_tab.cpp b/glslang/MachineIndependent/glslang_tab.cpp index 1348c8b..6a2eb40 100644 --- a/glslang/MachineIndependent/glslang_tab.cpp +++ b/glslang/MachineIndependent/glslang_tab.cpp @@ -4447,8 +4447,8 @@ yyreduce: if ((yyval.interm).function == 0) { // error recover - TString empty(""); - (yyval.interm).function = new TFunction(&empty, TType(EbtVoid), EOpNull); + TString* empty = NewPoolTString(""); + (yyval.interm).function = new TFunction(empty, TType(EbtVoid), EOpNull); } } #line 4455 "MachineIndependent/glslang_tab.cpp" /* yacc.c:1646 */ -- 2.7.4