OSDN Git Service

glcpp: Fix use-after-free error from #undef directive.
authorCarl Worth <cworth@cworth.org>
Tue, 20 Jul 2010 01:02:12 +0000 (18:02 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 21 Jul 2010 00:01:11 +0000 (17:01 -0700)
By taking advantage of the recently-added hash_table_remove function.

With this change, all existing tests are now valgrind-clean.

src/glsl/glcpp/glcpp-parse.y

index e5544fe..a2b54ef 100644 (file)
@@ -202,10 +202,7 @@ control_line:
 |      HASH_UNDEF IDENTIFIER NEWLINE {
                macro_t *macro = hash_table_find (parser->defines, $2);
                if (macro) {
-                       /* XXX: Need hash table to support a real way
-                        * to remove an element rather than prefixing
-                        * a new node with data of NULL like this. */
-                       hash_table_insert (parser->defines, NULL, $2);
+                       hash_table_remove (parser->defines, $2);
                        talloc_free (macro);
                }
                talloc_free ($2);