From eacc59c0163cbb63651d178121a1a5d06c44859e Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 17 Jan 2013 22:01:31 +0900 Subject: [PATCH] Build the field types array for enums, too. However, every element is the same: type_default's type_def. This fixes the segfault building qwaq introduced by the previous enum commit. --- tools/qfcc/source/obj_type.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tools/qfcc/source/obj_type.c b/tools/qfcc/source/obj_type.c index 3454448ba..20e9230fe 100644 --- a/tools/qfcc/source/obj_type.c +++ b/tools/qfcc/source/obj_type.c @@ -167,7 +167,7 @@ qfo_encode_struct (type_t *type) qfot_type_t *enc; qfot_struct_t *strct; def_t *def; - def_t **field_types = &def; + def_t **field_types; int i; int size; int offset; @@ -194,16 +194,18 @@ qfo_encode_struct (type_t *type) type->type_def = def; // avoid infinite recursion - if (type->meta != ty_enum) { - field_types = alloca (num_fields * sizeof (def_t *)); - for (i = 0, sym = type->t.symtab->symbols; sym; sym = sym->next) { - if (sym->sy_type != sy) - continue; - if (i == num_fields) - internal_error (0, "whoa, what happened?"); + field_types = alloca (num_fields * sizeof (def_t *)); + for (i = 0, sym = type->t.symtab->symbols; sym; sym = sym->next) { + if (sym->sy_type != sy) + continue; + if (i == num_fields) + internal_error (0, "whoa, what happened?"); + if (type->meta != ty_enum) { field_types[i] = qfo_encode_type (sym->type); - i++; + } else { + field_types[i] = type_default->type_def; } + i++; } for (i = 0, sym = type->t.symtab->symbols; sym; sym = sym->next) {