glsl2: strdup the field names used in dereference_record.
authorEric Anholt <eric@anholt.net>
Wed, 21 Jul 2010 00:17:47 +0000 (17:17 -0700)
committerEric Anholt <eric@anholt.net>
Wed, 21 Jul 2010 00:30:10 +0000 (17:30 -0700)
Otherwise, after linking and freeing the old data, the pointer would
dangle.  Partial fix for glsl1-struct*.

src/glsl/ir.cpp

index 1648848ecb6af1a84c45fd55d8c2451ca04ce7af..ba8ee7b9ac9aeeb926ce417ee3b6829e48e5aa05 100644 (file)
@@ -514,7 +514,7 @@ ir_dereference_record::ir_dereference_record(ir_rvalue *value,
 {
    this->ir_type = ir_type_dereference_record;
    this->record = value;
-   this->field = field;
+   this->field = talloc_strdup(this, field);
    this->type = (this->record != NULL)
       ? this->record->type->field_type(field) : glsl_type::error_type;
 }
@@ -527,7 +527,7 @@ ir_dereference_record::ir_dereference_record(ir_variable *var,
 
    this->ir_type = ir_type_dereference_record;
    this->record = new(ctx) ir_dereference_variable(var);
-   this->field = field;
+   this->field = talloc_strdup(this, field);
    this->type = (this->record != NULL)
       ? this->record->type->field_type(field) : glsl_type::error_type;
 }