]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
fix segfault from previous cherry-pick
authorWolfgang Bumiller <blub@speed.at>
Thu, 27 Dec 2012 13:43:31 +0000 (14:43 +0100)
committerWolfgang Bumiller <blub@speed.at>
Thu, 27 Dec 2012 13:43:31 +0000 (14:43 +0100)
ir.c

diff --git a/ir.c b/ir.c
index f7bc0527ce5a21dceb22790d4a063495539ace24..49f196efbe39e327815c40fb1bbfdbdd52daf178 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -1021,16 +1021,22 @@ ir_value* ir_value_vector_member(ir_value *self, unsigned int member)
     if (self->members[member])
         return self->members[member];
 
-    len = strlen(self->name);
-    name = (char*)mem_a(len + 3);
-    memcpy(name, self->name, len);
-    name[len+0] = '_';
-    name[len+1] = 'x' + member;
-    name[len+2] = '\0';
+    if (self->name) {
+        len = strlen(self->name);
+        name = (char*)mem_a(len + 3);
+        memcpy(name, self->name, len);
+        name[len+0] = '_';
+        name[len+1] = 'x' + member;
+        name[len+2] = '\0';
+    }
+    else
+        name = NULL;
+
     if (self->vtype == TYPE_VECTOR)
     {
         m = ir_value_var(name, self->store, TYPE_FLOAT);
-        mem_d(name);
+        if (name)
+            mem_d(name);
         if (!m)
             return NULL;
         m->context = self->context;
@@ -1043,7 +1049,8 @@ ir_value* ir_value_vector_member(ir_value *self, unsigned int member)
         if (self->fieldtype != TYPE_VECTOR)
             return NULL;
         m = ir_value_var(name, self->store, TYPE_FIELD);
-        mem_d(name);
+        if (name)
+            mem_d(name);
         if (!m)
             return NULL;
         m->fieldtype = TYPE_FLOAT;