nir/serialize: handle var->name being NULL
authorAlejandro Piñeiro <apinheiro@igalia.com>
Wed, 28 Feb 2018 12:01:56 +0000 (13:01 +0100)
committerAlejandro Piñeiro <apinheiro@igalia.com>
Thu, 1 Mar 2018 07:23:33 +0000 (08:23 +0100)
var->name could be NULL under ARB_gl_spirv for example. And in any
case, the code is already handing var name being NULL when reading a
variable, so it is consistent to do it writing a variable too.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/compiler/nir/nir_serialize.c

index 9fe46a675f601b323b9163b3ba66e2a4fa42a146..00df49c2ef3a5df1cff4489e8b3ae1b6eb793721 100644 (file)
@@ -137,7 +137,8 @@ write_variable(write_ctx *ctx, const nir_variable *var)
    write_add_object(ctx, var);
    encode_type_to_blob(ctx->blob, var->type);
    blob_write_uint32(ctx->blob, !!(var->name));
-   blob_write_string(ctx->blob, var->name);
+   if (var->name)
+      blob_write_string(ctx->blob, var->name);
    blob_write_bytes(ctx->blob, (uint8_t *) &var->data, sizeof(var->data));
    blob_write_uint32(ctx->blob, var->num_state_slots);
    blob_write_bytes(ctx->blob, (uint8_t *) var->state_slots,